Skip to content

Commit

Permalink
stores multiSigKeys as hex instead of utf8 (#4553)
Browse files Browse the repository at this point in the history
uses hex strings and stores multisig keys as buffers in the wallet db instead of
using utf8 strings

this more closely matches the precedent set with our other keys and may simplify
ser/de between TypeScript and Rust
  • Loading branch information
hughy authored Jan 17, 2024
1 parent 06a9f03 commit fc8855d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions ironfish/src/wallet/walletdb/accountValue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ describe('AccountValueEncoding', () => {
version: 1,
createdAt: null,
multiSigKeys: {
identifier: 'a',
keyPackage: 'b',
proofGenerationKey: 'c',
identifier: 'deaf',
keyPackage: 'beef',
proofGenerationKey: 'feed',
},
}
const buffer = encoder.serialize(value)
Expand Down
18 changes: 9 additions & 9 deletions ironfish/src/wallet/walletdb/accountValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ export class AccountValueEncoding implements IDatabaseEncoding<AccountValue> {
}

if (value.multiSigKeys) {
bw.writeVarString(value.multiSigKeys.identifier, 'utf8')
bw.writeVarString(value.multiSigKeys.keyPackage, 'utf8')
bw.writeVarString(value.multiSigKeys.proofGenerationKey, 'utf8')
bw.writeVarBytes(Buffer.from(value.multiSigKeys.identifier, 'hex'))
bw.writeVarBytes(Buffer.from(value.multiSigKeys.keyPackage, 'hex'))
bw.writeVarBytes(Buffer.from(value.multiSigKeys.proofGenerationKey, 'hex'))
}

return bw.render()
Expand Down Expand Up @@ -87,9 +87,9 @@ export class AccountValueEncoding implements IDatabaseEncoding<AccountValue> {
let multiSigKeys = undefined
if (hasMultiSigKeys) {
multiSigKeys = {
identifier: reader.readVarString('utf8'),
keyPackage: reader.readVarString('utf8'),
proofGenerationKey: reader.readVarString('utf8'),
identifier: reader.readVarBytes().toString('hex'),
keyPackage: reader.readVarBytes().toString('hex'),
proofGenerationKey: reader.readVarBytes().toString('hex'),
}
}

Expand Down Expand Up @@ -125,9 +125,9 @@ export class AccountValueEncoding implements IDatabaseEncoding<AccountValue> {
size += encoding.nonNullSize
}
if (value.multiSigKeys) {
size += bufio.sizeVarString(value.multiSigKeys.identifier, 'utf8')
size += bufio.sizeVarString(value.multiSigKeys.keyPackage, 'utf8')
size += bufio.sizeVarString(value.multiSigKeys.proofGenerationKey, 'utf8')
size += bufio.sizeVarString(value.multiSigKeys.identifier, 'hex')
size += bufio.sizeVarString(value.multiSigKeys.keyPackage, 'hex')
size += bufio.sizeVarString(value.multiSigKeys.proofGenerationKey, 'hex')
}

return size
Expand Down

0 comments on commit fc8855d

Please sign in to comment.