mirror of
https://github.com/fluencelabs/trust-graph
synced 2024-12-04 15:20:19 +00:00
remove std feature, add u64_backend feature
This commit is contained in:
parent
f3bce3023a
commit
e5b8a9c011
73
Cargo.lock
generated
73
Cargo.lock
generated
@ -32,7 +32,7 @@ version = "0.7.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
|
||||
dependencies = [
|
||||
"getrandom 0.2.10",
|
||||
"getrandom",
|
||||
"once_cell",
|
||||
"version_check",
|
||||
]
|
||||
@ -301,7 +301,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4d25555efacb0b5244cf1d35833d55d21abc916fff0eaad254b8e2453ea9b8ab"
|
||||
dependencies = [
|
||||
"ambient-authority",
|
||||
"rand 0.8.5",
|
||||
"rand",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -813,7 +813,6 @@ checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d"
|
||||
dependencies = [
|
||||
"curve25519-dalek 3.2.0",
|
||||
"ed25519 1.5.3",
|
||||
"rand 0.7.3",
|
||||
"serde",
|
||||
"serde_bytes",
|
||||
"sha2 0.9.9",
|
||||
@ -1003,7 +1002,7 @@ dependencies = [
|
||||
"libp2p-identity",
|
||||
"multihash 0.18.1",
|
||||
"quickcheck",
|
||||
"rand 0.8.5",
|
||||
"rand",
|
||||
"serde",
|
||||
"serde_bytes",
|
||||
"sha2 0.10.7",
|
||||
@ -1067,17 +1066,6 @@ dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.1.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi 0.9.0+wasi-snapshot-preview1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.10"
|
||||
@ -2152,7 +2140,7 @@ checksum = "588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6"
|
||||
dependencies = [
|
||||
"env_logger 0.8.4",
|
||||
"log",
|
||||
"rand 0.8.5",
|
||||
"rand",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2164,19 +2152,6 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
|
||||
dependencies = [
|
||||
"getrandom 0.1.16",
|
||||
"libc",
|
||||
"rand_chacha 0.2.2",
|
||||
"rand_core 0.5.1",
|
||||
"rand_hc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.5"
|
||||
@ -2184,20 +2159,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha 0.3.1",
|
||||
"rand_chacha",
|
||||
"rand_core 0.6.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core 0.5.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.3.1"
|
||||
@ -2213,9 +2178,6 @@ name = "rand_core"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
|
||||
dependencies = [
|
||||
"getrandom 0.1.16",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
@ -2223,16 +2185,7 @@ version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
dependencies = [
|
||||
"getrandom 0.2.10",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
|
||||
dependencies = [
|
||||
"rand_core 0.5.1",
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2281,7 +2234,7 @@ version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b"
|
||||
dependencies = [
|
||||
"getrandom 0.2.10",
|
||||
"getrandom",
|
||||
"redox_syscall 0.2.16",
|
||||
"thiserror",
|
||||
]
|
||||
@ -2871,7 +2824,7 @@ dependencies = [
|
||||
"fluence-keypair",
|
||||
"log",
|
||||
"nonempty",
|
||||
"rand 0.8.5",
|
||||
"rand",
|
||||
"ref-cast",
|
||||
"serde",
|
||||
"sha2 0.10.7",
|
||||
@ -2978,7 +2931,7 @@ version = "1.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d"
|
||||
dependencies = [
|
||||
"getrandom 0.2.10",
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -3045,12 +2998,6 @@ dependencies = [
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.9.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.10.0+wasi-snapshot-preview1"
|
||||
@ -3392,7 +3339,7 @@ dependencies = [
|
||||
"memfd",
|
||||
"memoffset 0.6.5",
|
||||
"paste",
|
||||
"rand 0.8.5",
|
||||
"rand",
|
||||
"rustix 0.36.15",
|
||||
"wasmtime-asm-macros",
|
||||
"wasmtime-environ",
|
||||
|
@ -10,7 +10,7 @@ repository = "https://github.com/fluencelabs/trust-graph"
|
||||
[dependencies]
|
||||
serde = { version = "1.0.118", features = ["derive"] }
|
||||
bs58 = "0.5.0"
|
||||
ed25519-dalek = { version = "1.0.1", features = ["serde", "std", "u32_backend"], default-features = false }
|
||||
ed25519-dalek = { version = "1.0.1", features = ["serde", "u64_backend"], default-features = false }
|
||||
thiserror = "1.0.23"
|
||||
lazy_static = "1.4"
|
||||
sha2 = "0.10.6"
|
||||
|
@ -53,12 +53,17 @@ impl Keypair {
|
||||
kp.zeroize();
|
||||
Keypair(k)
|
||||
})
|
||||
.map_err(DecodingError::Ed25519)
|
||||
.map_err(|_| DecodingError::Ed25519())
|
||||
}
|
||||
|
||||
/// Sign a message using the private key of this keypair.
|
||||
pub fn sign(&self, msg: &[u8]) -> Result<Vec<u8>, SigningError> {
|
||||
Ok(self.0.try_sign(msg)?.to_bytes().to_vec())
|
||||
Ok(self
|
||||
.0
|
||||
.try_sign(msg)
|
||||
.map_err(|_| SigningError::Ed25519())?
|
||||
.to_bytes()
|
||||
.to_vec())
|
||||
}
|
||||
|
||||
/// Get the public key of this keypair.
|
||||
@ -128,9 +133,8 @@ impl PublicKey {
|
||||
pub fn verify(&self, msg: &[u8], sig: &[u8]) -> Result<(), VerificationError> {
|
||||
ed25519::Signature::try_from(sig)
|
||||
.and_then(|s| self.0.verify(msg, &s))
|
||||
.map_err(|e| {
|
||||
.map_err(|_| {
|
||||
VerificationError::Ed25519(
|
||||
e,
|
||||
bs58::encode(sig).into_string(),
|
||||
bs58::encode(self.0.as_bytes()).into_string(),
|
||||
)
|
||||
@ -146,7 +150,7 @@ impl PublicKey {
|
||||
/// Decode a public key from a byte array as produced by `encode`.
|
||||
pub fn decode(bytes: &[u8]) -> Result<Self, DecodingError> {
|
||||
ed25519::PublicKey::from_bytes(bytes)
|
||||
.map_err(DecodingError::Ed25519)
|
||||
.map_err(|_| DecodingError::Ed25519())
|
||||
.map(PublicKey)
|
||||
}
|
||||
}
|
||||
@ -192,7 +196,8 @@ impl SecretKey {
|
||||
/// returned.
|
||||
pub fn from_bytes(mut sk_bytes: impl AsMut<[u8]>) -> Result<Self, DecodingError> {
|
||||
let sk_bytes = sk_bytes.as_mut();
|
||||
let secret = ed25519::SecretKey::from_bytes(&*sk_bytes).map_err(DecodingError::Ed25519)?;
|
||||
let secret =
|
||||
ed25519::SecretKey::from_bytes(&*sk_bytes).map_err(|_| DecodingError::Ed25519())?;
|
||||
sk_bytes.zeroize();
|
||||
Ok(SecretKey(secret))
|
||||
}
|
||||
|
@ -31,12 +31,8 @@ pub enum Error {
|
||||
/// An error during decoding of key material.
|
||||
#[derive(ThisError, Debug)]
|
||||
pub enum DecodingError {
|
||||
#[error("Failed to decode with ed25519: {0}")]
|
||||
Ed25519(
|
||||
#[from]
|
||||
#[source]
|
||||
ed25519_dalek::ed25519::Error,
|
||||
),
|
||||
#[error("Failed to decode with ed25519")]
|
||||
Ed25519(),
|
||||
#[error("Invalid type prefix")]
|
||||
InvalidTypeByte,
|
||||
#[error("Cannot decode public key from base58 :{0}")]
|
||||
@ -50,17 +46,13 @@ pub enum DecodingError {
|
||||
/// An error during signing of a message.
|
||||
#[derive(ThisError, Debug)]
|
||||
pub enum SigningError {
|
||||
#[error("Failed to sign with ed25519: {0}")]
|
||||
Ed25519(
|
||||
#[from]
|
||||
#[source]
|
||||
ed25519_dalek::ed25519::Error,
|
||||
),
|
||||
#[error("Failed to sign with ed25519")]
|
||||
Ed25519(),
|
||||
}
|
||||
|
||||
/// An error during verification of a message.
|
||||
#[derive(ThisError, Debug)]
|
||||
pub enum VerificationError {
|
||||
#[error("Failed to verify signature {1} with {2} ed25519 public key: {0}")]
|
||||
Ed25519(#[source] ed25519_dalek::ed25519::Error, String, String),
|
||||
#[error("Failed to verify signature {0} with {1} ed25519 public key")]
|
||||
Ed25519(String, String),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user