Skip to content

Commit 86513f9

Browse files
Merge branch 'HSM-706'
2 parents 574b3c4 + c060690 commit 86513f9

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

modules/bitgo/test/v2/unit/internal/opengpgUtils.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as assert from 'assert';
55

66
import { openpgpUtils } from '@bitgo/sdk-core';
77
import { ecc as secp256k1 } from '@bitgo/utxo-lib';
8+
import * as sinon from 'sinon';
89

910
const sodium = require('libsodium-wrappers-sumo');
1011

@@ -181,6 +182,24 @@ describe('OpenGPG Utils Tests', function () {
181182
isValid = await openpgpUtils.verifySharedDataProof(senderKey.publicKey, proof, dataToProofArray);
182183
isValid.should.be.false();
183184
});
185+
186+
it('should be able verify data proof if created in the future', async function () {
187+
const sharedData1 = crypto.randomBytes(32).toString('hex');
188+
const sharedData2 = crypto.randomBytes(32).toString('hex');
189+
const dataToProofArray = [
190+
{ name: 's1', value: sharedData1 },
191+
{ name: 's2', value: sharedData2 },
192+
];
193+
const proof = await openpgpUtils.createSharedDataProof(
194+
senderKey.privateKey,
195+
otherKey.publicKey,
196+
dataToProofArray
197+
);
198+
const clock = sinon.useFakeTimers(new Date('2001-02-14T12:00:00Z').getTime());
199+
const isValid = await openpgpUtils.verifySharedDataProof(senderKey.publicKey, proof, dataToProofArray);
200+
isValid.should.be.true();
201+
clock.restore();
202+
});
184203
});
185204

186205
describe('encrypt and decrypt with signing', function () {

modules/sdk-core/src/bitgo/utils/opengpgUtils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,13 @@ export async function verifySharedDataProof(
132132
const senderPubKey = await pgp.readKey({ armoredKey: senderPubKeyArm });
133133
const signedKey = await pgp.readKey({ armoredKey: keyWithNotation });
134134
if (
135-
!(await verifyPrimaryUserWrapper(signedKey, senderPubKey, true).then((values) =>
135+
!(await verifyPrimaryUserWrapper(signedKey, senderPubKey, false).then((values) =>
136136
_.some(values, (value) => value.valid)
137137
))
138138
) {
139139
return false;
140140
}
141-
const primaryUser = await signedKey.getPrimaryUser();
141+
const primaryUser = await signedKey.getPrimaryUser(null as unknown as undefined);
142142
const anyInvalidProof = _.some(
143143
// @ts-ignore
144144
primaryUser.user.otherCertifications[0].rawNotations,
@@ -165,7 +165,7 @@ export async function createSharedDataProof(
165165
const dateTime = new Date();
166166
// UserId Packet.
167167
const userIdPkt = new pgp.UserIDPacket();
168-
const primaryUser = await publicKeyToCert.getPrimaryUser();
168+
const primaryUser = await publicKeyToCert.getPrimaryUser(null as unknown as undefined);
169169
// @ts-ignore
170170
userIdPkt.userID = primaryUser.user.userID.userID;
171171
// Signature packet.

modules/sdk-lib-mpc/src/tss/ecdsa-dkls/commsLayer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ export async function encryptAndDetachSignData(
4949
showVersion: false,
5050
showComment: false,
5151
},
52+
date: null as unknown as undefined,
5253
});
5354
const signature = await pgp.sign({
5455
message,
@@ -89,6 +90,7 @@ export async function decryptAndVerifySignedData(
8990
showComment: false,
9091
},
9192
format: 'binary',
93+
date: null as unknown as undefined,
9294
});
9395
const verificationResult = await pgp.verify({
9496
message: await pgp.createMessage({ binary: decryptedMessage.data }),

0 commit comments

Comments
 (0)