-
Notifications
You must be signed in to change notification settings - Fork 8
add recovery bit to allow restoring the public key #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,16 +18,16 @@ export const deleteSpace = ({ author, id, previousEventHash }: Params): Effect.E | |
previousEventHash, | ||
}; | ||
const encodedTransaction = stringToUint8Array(canonicalize(transaction)); | ||
const signature = secp256k1 | ||
.sign(encodedTransaction, hexToBytes(author.signaturePrivateKey), { prehash: true }) | ||
.toCompactHex(); | ||
const signatureResult = secp256k1.sign(encodedTransaction, hexToBytes(author.signaturePrivateKey), { | ||
prehash: true, | ||
}); | ||
|
||
const event: DeleteSpaceEvent = { | ||
transaction, | ||
author: { | ||
accountId: author.accountId, | ||
publicKey: author.signaturePublicKey, | ||
signature, | ||
signature: signatureResult.toCompactHex(), | ||
|
||
recovery: signatureResult.recovery, | ||
}, | ||
}; | ||
return Effect.succeed(event); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, one more thing - I think this might not be necessary, as recoverPublicKey essentially verifies the signature too (it will only give the correct public key if the corresponding private key signed that message)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might even be redundant, because the public key is recovered from the signature, so it will probably always be valid - I think we should instead validate that the public key is a valid signing key for the author's accountId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, as a next step we ned to retrieve the publicKey from the author and pass it in. At the moment afaik I need to reconstruct it, since it's a required argument for the
verify
function.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I mean is we don't need to call the
verify
function. Once you retrieve the author's public key and compare it to the one you recovered, you have essentially verified the signatureThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added an issue for it: #138