Skip to content

Commit

Permalink
latest
Browse files Browse the repository at this point in the history
  • Loading branch information
onewayfunc committed Oct 23, 2022
1 parent ea475a4 commit 369ae9d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 6 additions & 5 deletions api/src/xfr/sig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use ark_serialize::{Flags, SWFlags};
use digest::consts::U64;
use ed25519_dalek::{
ExpandedSecretKey, PublicKey as Ed25519PublicKey, SecretKey as Ed25519SecretKey,
Signature as Ed25519Signature, Verifier,
Signature as Ed25519Signature, Signer, Verifier,
};
use libsecp256k1::{
curve::{Affine as LibSecp256k1G1, FieldStorage, Scalar as LibSecp256k1Scalar},
Expand Down Expand Up @@ -377,9 +377,10 @@ impl XfrSecretKey {
pub fn sign(&self, message: &[u8]) -> Result<XfrSignature> {
match self {
XfrSecretKey::Ed25519(sk) => {
let pk: Ed25519PublicKey = sk.into();
let expanded: ExpandedSecretKey = sk.into();
let sign = expanded.sign(message, &pk);
let sign = ed25519_dalek::Keypair::from(
Ed25519SecretKey::from_bytes(&sk.to_bytes()).unwrap(),
)
.sign(message);
Ok(XfrSignature::Ed25519(sign))
}
XfrSecretKey::Secp256k1(sk) => {
Expand Down Expand Up @@ -502,7 +503,7 @@ impl XfrKeyPair {
let kp = ed25519_dalek::Keypair::generate(prng);
XfrKeyPair {
pub_key: XfrPublicKey(XfrPublicKeyInner::Ed25519(kp.public)),
sec_key: XfrSecretKey::Ed25519(kp.secret),
sec_key: XfrSecretKey::Ed25519(kp.secret_key()),
}
}

Expand Down
5 changes: 3 additions & 2 deletions crypto/src/basic/hybrid_encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ mod test {
let keypair = Keypair::generate(&mut prng);
let (from_pk_key, encoded_rand) =
symmetric_key_from_ed25519_public_key(&mut prng, &keypair.public);
let from_sk_key = symmetric_key_from_ed25519_secret_key(&keypair.secret, &encoded_rand);
let from_sk_key =
symmetric_key_from_ed25519_secret_key(&keypair.secret_key(), &encoded_rand);
assert_eq!(from_pk_key, from_sk_key);
}

Expand All @@ -314,7 +315,7 @@ mod test {
let msg = b"this is another message";

let cipherbox = hybrid_encrypt_ed25519(&mut prng, &key_pair.public, msg);
let plaintext = hybrid_decrypt_with_ed25519_secret_key(&cipherbox, &key_pair.secret);
let plaintext = hybrid_decrypt_with_ed25519_secret_key(&cipherbox, &key_pair.secret_key());
assert_eq!(msg, plaintext.as_slice());
}
}

0 comments on commit 369ae9d

Please sign in to comment.