Skip to content

Commit ca8fbc2

Browse files
authored
sign command returns signature as Buffer (#3)
1 parent 5912f00 commit ca8fbc2

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

src/index.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ export default class IronfishApp extends GenericApp {
8282
const returnCode = errorCodeData[0] * 256 + errorCodeData[1]
8383
let errorMessage = errorCodeToString(returnCode)
8484

85-
let signatures: Buffer[] = []
86-
8785
if (
8886
returnCode === LedgerError.BadKeyHandle ||
8987
returnCode === LedgerError.DataIsInvalid ||
@@ -92,15 +90,11 @@ export default class IronfishApp extends GenericApp {
9290
errorMessage = `${errorMessage} : ${response.subarray(0, response.length - 2).toString('ascii')}`
9391
}
9492

95-
if (returnCode === LedgerError.NoErrors && response.length > 2) {
96-
const signaturesLen = (response.length - 2) / REDJUBJUB_SIGNATURE_LEN
97-
for (let i = 0; i < signaturesLen; i++) {
98-
const tmpSignature = response.subarray(i * REDJUBJUB_SIGNATURE_LEN, i * REDJUBJUB_SIGNATURE_LEN + REDJUBJUB_SIGNATURE_LEN)
99-
signatures.push(tmpSignature)
100-
}
93+
if (returnCode === LedgerError.NoErrors && response.length == (2 + REDJUBJUB_SIGNATURE_LEN)) {
94+
const signature = response.subarray(0, REDJUBJUB_SIGNATURE_LEN)
10195

10296
return {
103-
signatures,
97+
signature,
10498
returnCode,
10599
errorMessage,
106100
}

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface ResponseProofGenKey extends ResponseBase {
2424
}
2525

2626
export interface ResponseSign extends ResponseBase {
27-
signatures?: Buffer[]
27+
signature?: Buffer
2828
}
2929

3030
export enum IronfishKeys {

0 commit comments

Comments
 (0)