Skip to content

Commit 40b367b

Browse files
authored
Merge pull request #5364 from iron-fish/rahul/make-secret-optional-multisigSecrets
Rahul/make secret optional multisig secrets
2 parents 1b777bf + 7674888 commit 40b367b

16 files changed

+107
-79
lines changed

ironfish/src/rpc/routes/wallet/exportAccount.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ describe('Route wallet/exportAccount', () => {
127127
),
128128
)
129129

130-
const multisigSecret = await routeTest.node.wallet.walletDb.getMultisigSecret(
130+
const multisigIdentity = await routeTest.node.wallet.walletDb.getMultisigIdentity(
131131
Buffer.from(participants[0].identity, 'hex'),
132132
)
133-
Assert.isNotUndefined(multisigSecret)
133+
Assert.isNotUndefined(multisigIdentity)
134134

135135
// Initialize the group though TDK and import one of the accounts generated
136136
const trustedDealerPackage = (
@@ -157,6 +157,9 @@ describe('Route wallet/exportAccount', () => {
157157
})
158158

159159
expect(response.status).toBe(200)
160+
161+
Assert.isNotUndefined(multisigIdentity.secret)
162+
160163
expect(JSON.parse(response.content.account)).toMatchObject({
161164
name: accountNames[0],
162165
spendingKey: null,
@@ -165,7 +168,7 @@ describe('Route wallet/exportAccount', () => {
165168
outgoingViewKey: trustedDealerPackage.outgoingViewKey,
166169
publicAddress: trustedDealerPackage.publicAddress,
167170
multisigKeys: {
168-
secret: multisigSecret.secret.toString('hex'),
171+
secret: multisigIdentity.secret.toString('hex'),
169172
publicKeyPackage: trustedDealerPackage.publicKeyPackage,
170173
},
171174
})
@@ -185,10 +188,10 @@ describe('Route wallet/exportAccount', () => {
185188
),
186189
)
187190

188-
const multisigSecret = await routeTest.node.wallet.walletDb.getMultisigSecret(
191+
const multisigIdentity = await routeTest.node.wallet.walletDb.getMultisigIdentity(
189192
Buffer.from(participants[0].identity, 'hex'),
190193
)
191-
Assert.isNotUndefined(multisigSecret)
194+
Assert.isNotUndefined(multisigIdentity)
192195

193196
// Initialize the group though TDK and import one of the accounts generated
194197
const trustedDealerPackage = (

ironfish/src/rpc/routes/wallet/importAccount.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ describe('Route wallet/importAccount', () => {
370370
const secret = new multisig.ParticipantSecret(Buffer.from(key, 'hex'))
371371
const identity = secret.toIdentity()
372372

373-
await routeTest.node.wallet.walletDb.putMultisigSecret(identity.serialize(), {
373+
await routeTest.node.wallet.walletDb.putMultisigIdentity(identity.serialize(), {
374374
secret: secret.serialize(),
375375
name: testCaseFile,
376376
})

ironfish/src/rpc/routes/wallet/multisig/createParticipant.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('Route wallet/multisig/createParticipant', () => {
4545
const name = 'identity'
4646
const response = await routeTest.client.wallet.multisig.createParticipant({ name })
4747

48-
const secretValue = await routeTest.node.wallet.walletDb.getMultisigSecret(
48+
const secretValue = await routeTest.node.wallet.walletDb.getMultisigIdentity(
4949
Buffer.from(response.content.identity, 'hex'),
5050
)
5151
Assert.isNotUndefined(secretValue)

ironfish/src/rpc/routes/wallet/multisig/dkg/round1.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('Route multisig/dkg/round1', () => {
3333
participantName,
3434
)
3535
Assert.isNotUndefined(secretValue)
36-
const secret = new multisig.ParticipantSecret(secretValue.secret)
36+
const secret = new multisig.ParticipantSecret(secretValue)
3737
secret.decryptData(Buffer.from(response.content.round1SecretPackage, 'hex'))
3838
})
3939

ironfish/src/rpc/routes/wallet/multisig/dkg/round1.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ routes.register<typeof DkgRound1RequestSchema, DkgRound1Response>(
5555
}
5656

5757
const participantIdentities = participants.map((p) => p.identity)
58-
const selfIdentity = new multisig.ParticipantSecret(multisigSecret.secret)
58+
const selfIdentity = new multisig.ParticipantSecret(multisigSecret)
5959
.toIdentity()
6060
.serialize()
6161
.toString('hex')

ironfish/src/rpc/routes/wallet/multisig/dkg/round2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ routes.register<typeof DkgRound2RequestSchema, DkgRound2Response>(
5151
)
5252
}
5353

54-
const secret = multisigSecret.secret.toString('hex')
54+
const secret = multisigSecret.toString('hex')
5555

5656
const packages = multisig.dkgRound2(secret, round1SecretPackage, round1PublicPackages)
5757

ironfish/src/rpc/routes/wallet/multisig/dkg/round3.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ routes.register<typeof DkgRound3RequestSchema, DkgRound3Response>(
5757
)
5858
}
5959

60-
const secret = new multisig.ParticipantSecret(multisigSecret.secret)
60+
const secret = new multisig.ParticipantSecret(multisigSecret)
6161
const identity = secret.toIdentity().serialize().toString('hex')
6262

6363
const {

ironfish/src/rpc/routes/wallet/multisig/getIdentities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ routes.register<typeof GetIdentitiesRequestSchema, GetIdentitiesResponse>(
4545
for await (const [
4646
identity,
4747
{ name },
48-
] of context.wallet.walletDb.multisigSecrets.getAllIter()) {
48+
] of context.wallet.walletDb.multisigIdentities.getAllIter()) {
4949
identities.push({
5050
name,
5151
identity: identity.toString('hex'),

ironfish/src/rpc/routes/wallet/multisig/getIdentity.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,12 @@ routes.register<typeof GetIdentityRequestSchema, GetIdentityResponse>(
3636

3737
const { name } = request.data
3838

39-
const record = await context.wallet.walletDb.getMultisigSecretByName(name)
40-
if (record === undefined) {
39+
const secret = await context.wallet.walletDb.getMultisigSecretByName(name)
40+
if (secret === undefined) {
4141
throw new RpcValidationError(`No identity found with name ${name}`, 404)
4242
}
4343

44-
const secret = new multisig.ParticipantSecret(record.secret)
45-
const identity = secret.toIdentity()
44+
const identity = new multisig.ParticipantSecret(secret).toIdentity()
4645

4746
request.end({ identity: identity.serialize().toString('hex') })
4847
},

ironfish/src/wallet/exporter/encryption.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ export async function decryptEncodedAccount(
3333
if (encrypted.startsWith(BASE64_JSON_MULTISIG_ENCRYPTED_ACCOUNT_PREFIX)) {
3434
const encoded = encrypted.slice(BASE64_JSON_MULTISIG_ENCRYPTED_ACCOUNT_PREFIX.length)
3535

36-
for await (const { secret: secretBuffer } of wallet.walletDb.getMultisigSecrets()) {
36+
for await (const { secret: secretBuffer } of wallet.walletDb.getMultisigIdentities()) {
37+
if (secretBuffer === undefined) {
38+
continue
39+
}
40+
3741
const secret = new multisig.ParticipantSecret(secretBuffer)
3842
const decrypted = decryptEncodedAccountWithMultisigSecret(encoded, secret)
3943

0 commit comments

Comments
 (0)