-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Declare Ed25519Signature and use it with Ed25519PrivateKey and Public…
…Key, and same for Secp256k1.
- Loading branch information
Showing
9 changed files
with
162 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,46 @@ | ||
// use crate::prelude::*; | ||
use crate::prelude::*; | ||
|
||
// use radix_engine_common::crypto::Ed25519Signature as ScryptoEd25519Signature; | ||
use radix_engine_common::crypto::Ed25519Signature as ScryptoEd25519Signature; | ||
|
||
// /// Represents an ED25519 signature. | ||
// #[derive( | ||
// Clone, | ||
// PartialEq, | ||
// Eq, | ||
// PartialOrd, | ||
// Ord, | ||
// Hash, | ||
// SerializeDisplay, | ||
// DeserializeFromStr, | ||
// derive_more::Display, | ||
// derive_more::Debug, | ||
// uniffi::Record, | ||
// )] | ||
// #[display("{}", self.to_hex())] | ||
// #[debug("{}", self.to_hex())] | ||
// pub struct Ed25519Signature { | ||
// pub bytes: BagOfBytes, | ||
// } | ||
/// Represents an ED25519 signature. | ||
#[derive( | ||
Clone, | ||
PartialEq, | ||
Eq, | ||
PartialOrd, | ||
Ord, | ||
Hash, | ||
derive_more::Display, | ||
derive_more::Debug, | ||
derive_more::FromStr, | ||
uniffi::Record, | ||
)] | ||
#[display("{}", self.to_hex())] | ||
#[debug("{}", self.to_hex())] | ||
pub struct Ed25519Signature { | ||
pub bytes: Hex64Bytes, | ||
} | ||
|
||
impl From<ScryptoEd25519Signature> for Ed25519Signature { | ||
fn from(value: ScryptoEd25519Signature) -> Self { | ||
Self { | ||
bytes: Hex64Bytes::from_bytes(&value.0), | ||
} | ||
} | ||
} | ||
|
||
impl From<Ed25519Signature> for ScryptoEd25519Signature { | ||
fn from(value: Ed25519Signature) -> Self { | ||
ScryptoEd25519Signature(value.bytes.bytes()) | ||
} | ||
} | ||
|
||
impl Ed25519Signature { | ||
pub fn to_bytes(&self) -> Vec<u8> { | ||
self.bytes.to_vec() | ||
} | ||
|
||
pub fn to_hex(&self) -> String { | ||
hex_encode(self.to_bytes()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,47 @@ | ||
// use crate::prelude::*; | ||
use crate::prelude::*; | ||
|
||
// use radix_engine_common::crypto::Secp256k1Signature as ScryptoSecp256k1Signature; | ||
use radix_engine_common::crypto::Secp256k1Signature as ScryptoSecp256k1Signature; | ||
|
||
/// Represents an Secp256k1 signature. | ||
#[derive( | ||
Clone, | ||
PartialEq, | ||
Eq, | ||
PartialOrd, | ||
Ord, | ||
Hash, | ||
derive_more::Display, | ||
derive_more::Debug, | ||
derive_more::FromStr, | ||
uniffi::Record, | ||
)] | ||
#[display("{}", self.to_hex())] | ||
#[debug("{}", self.to_hex())] | ||
pub struct Secp256k1Signature { | ||
// recovery id + signature | ||
pub bytes: Hex65Bytes, | ||
} | ||
|
||
impl From<ScryptoSecp256k1Signature> for Secp256k1Signature { | ||
fn from(value: ScryptoSecp256k1Signature) -> Self { | ||
Self { | ||
bytes: Hex65Bytes::from_bytes(&value.0), | ||
} | ||
} | ||
} | ||
|
||
impl From<Secp256k1Signature> for ScryptoSecp256k1Signature { | ||
fn from(value: Secp256k1Signature) -> Self { | ||
ScryptoSecp256k1Signature(value.bytes.bytes()) | ||
} | ||
} | ||
|
||
impl Secp256k1Signature { | ||
pub fn to_bytes(&self) -> Vec<u8> { | ||
self.bytes.to_vec() | ||
} | ||
|
||
pub fn to_hex(&self) -> String { | ||
hex_encode(self.to_bytes()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,30 @@ | ||
// use crate::prelude::*; | ||
use crate::prelude::*; | ||
|
||
// #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
// pub enum SignatureV1 { | ||
// Secp256k1(Secp256k1Signature), | ||
// Ed25519(Ed25519Signature), | ||
// } | ||
#[derive( | ||
Clone, | ||
PartialEq, | ||
Eq, | ||
PartialOrd, | ||
Ord, | ||
Hash, | ||
EnumAsInner, | ||
derive_more::Display, | ||
derive_more::Debug, | ||
uniffi::Enum, | ||
)] | ||
pub enum Signature { | ||
Secp256k1 { value: Secp256k1Signature }, | ||
Ed25519 { value: Ed25519Signature }, | ||
} | ||
|
||
// impl From<Secp256k1Signature> for SignatureV1 { | ||
// fn from(signature: Secp256k1Signature) -> Self { | ||
// Self::Secp256k1(signature) | ||
// } | ||
// } | ||
impl From<Secp256k1Signature> for Signature { | ||
fn from(signature: Secp256k1Signature) -> Self { | ||
Self::Secp256k1 { value: signature } | ||
} | ||
} | ||
|
||
// impl From<Ed25519Signature> for SignatureV1 { | ||
// fn from(signature: Ed25519Signature) -> Self { | ||
// Self::Ed25519(signature) | ||
// } | ||
// } | ||
|
||
// #[derive(Debug, Clone, Eq, PartialEq, ManifestSbor)] | ||
// #[sbor(transparent)] | ||
// pub struct NotarySignatureV1(pub SignatureV1); | ||
impl From<Ed25519Signature> for Signature { | ||
fn from(signature: Ed25519Signature) -> Self { | ||
Self::Ed25519 { value: signature } | ||
} | ||
} |