Skip to content
Snippets Groups Projects

Resolve "Create PublicKey, PrivateKey and Keypair enum"

Merged Éloïs requested to merge 77-create-publickey-privatekey-and-keypair-enum into dev
1 unresolved thread

Closes #77 (closed)

Edited by Éloïs

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
211 serializer.serialize_str(&format!("{}", self))
212 }
213 }
214
215 impl PublicKey for PubKey {
216 type Signature = Sig;
217
218 fn from_base58(_base58_string: &str) -> Result<Self, BaseConvertionError> {
219 unimplemented!()
220 }
221 fn verify(&self, message: &[u8], signature: &Self::Signature) -> bool {
222 match *self {
223 PubKey::Ed25519(ed25519_pubkey) => if let Sig::Ed25519(ed25519_sig) = signature {
224 ed25519_pubkey.verify(message, ed25519_sig)
225 } else {
226 panic!("Try to verify a signature with public key of a different algorithm !\nSignature={:?}\nPublickey={:?}", signature, self)
  • It should not panic, only return false. @librelois

    Edited by nanocryk
  • Author Owner

    No. Returning panic will help a lot in debugging the future implementation of a new algorithm. If one returns false one cannot discern the case of an invalid signature from the case of the use of a bad algo

  • So each time a document with a "variable keytype" contains a signature incompatible with the public key is checked, it will panic ?

    There should be unit tests to verify future implementations of algorithms, but I think this kind of behavior should not be present in running nodes. If signature is not of good type, it's still an invalid signature.

  • Please register or sign in to reply
  • changed milestone to %v0.3 Minimal mirror node

  • Please register or sign in to reply
    Loading