Refine Ed25519 byte arrays to ed25519-zebra types.
This commit is contained in:
parent
2e04610be3
commit
60f3f35d89
|
@ -268,6 +268,19 @@ version = "0.1.5"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
|
||||
|
||||
[[package]]
|
||||
name = "curve25519-dalek"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26778518a7f6cffa1d25a44b602b62b979bd88adb9e99ffec546998cf3404839"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"digest",
|
||||
"rand_core 0.5.1",
|
||||
"subtle",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "darling"
|
||||
version = "0.10.2"
|
||||
|
@ -312,6 +325,19 @@ dependencies = [
|
|||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ed25519-zebra"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dd3113b0008c4cc23688f2a0b9bbffe08d71ade8db480b43e1635c469e1f22b"
|
||||
dependencies = [
|
||||
"curve25519-dalek",
|
||||
"rand_core 0.5.1",
|
||||
"serde",
|
||||
"sha2",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fake-simd"
|
||||
version = "0.1.2"
|
||||
|
@ -1644,6 +1670,7 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"byteorder",
|
||||
"chrono",
|
||||
"ed25519-zebra",
|
||||
"futures",
|
||||
"hex",
|
||||
"proptest",
|
||||
|
|
|
@ -13,8 +13,10 @@ byteorder = "1.3"
|
|||
chrono = "0.4"
|
||||
hex = "0.4"
|
||||
sha2 = "0.8"
|
||||
redjubjub = "0.1"
|
||||
futures = "0.3"
|
||||
# ZF deps
|
||||
redjubjub = "0.1"
|
||||
ed25519-zebra = "0.1"
|
||||
|
||||
[dev-dependencies]
|
||||
proptest = "0.9"
|
||||
|
|
|
@ -69,12 +69,9 @@ pub struct JoinSplitData<P: ZkSnarkProof> {
|
|||
/// all `JoinSplit`s.
|
||||
pub rest: Vec<JoinSplit<P>>,
|
||||
/// The public key for the JoinSplit signature.
|
||||
// XXX refine to a Zcash-flavored Ed25519 pubkey.
|
||||
pub pub_key: [u8; 32],
|
||||
pub pub_key: ed25519_zebra::PublicKeyBytes,
|
||||
/// The JoinSplit signature.
|
||||
// XXX refine to a Zcash-flavored Ed25519 signature.
|
||||
// for now it's [u64; 8] rather than [u8; 64] to get trait impls
|
||||
pub sig: [u64; 8],
|
||||
pub sig: ed25519_zebra::Signature,
|
||||
}
|
||||
|
||||
impl<P: ZkSnarkProof> JoinSplitData<P> {
|
||||
|
|
|
@ -125,18 +125,8 @@ impl<P: ZkSnarkProof> ZcashSerialize for JoinSplitData<P> {
|
|||
for joinsplit in self.joinsplits() {
|
||||
joinsplit.zcash_serialize(&mut writer)?;
|
||||
}
|
||||
writer.write_all(&self.pub_key[..])?;
|
||||
// XXX very ugly, this happens because we used a [u64; 8] instead of
|
||||
// [u8; 64] to get trait impls and it will disappear when we refine to
|
||||
// Zcash-flavored Ed25519.
|
||||
writer.write_all(
|
||||
&{
|
||||
use byteorder::ByteOrder;
|
||||
let mut bytes = [0u8; 64];
|
||||
LittleEndian::write_u64_into(&self.sig[..], &mut bytes);
|
||||
bytes
|
||||
}[..],
|
||||
)?;
|
||||
writer.write_all(&<[u8; 32]>::from(self.pub_key)[..])?;
|
||||
writer.write_all(&<[u8; 64]>::from(self.sig)[..])?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -152,16 +142,8 @@ impl<P: ZkSnarkProof> ZcashDeserialize for Option<JoinSplitData<P>> {
|
|||
for _ in 0..(n - 1) {
|
||||
rest.push(JoinSplit::zcash_deserialize(&mut reader)?);
|
||||
}
|
||||
let pub_key = reader.read_32_bytes()?;
|
||||
// XXX this is horrible, see above, will be removed with type refinement
|
||||
let sig = {
|
||||
use byteorder::ByteOrder;
|
||||
let mut bytes = [0u8; 64];
|
||||
reader.read_exact(&mut bytes[..])?;
|
||||
let mut u64s = [0u64; 8];
|
||||
LittleEndian::read_u64_into(&bytes, &mut u64s[..]);
|
||||
u64s
|
||||
};
|
||||
let pub_key = reader.read_32_bytes()?.into();
|
||||
let sig = reader.read_64_bytes()?.into();
|
||||
Ok(Some(JoinSplitData {
|
||||
first,
|
||||
rest,
|
||||
|
|
Loading…
Reference in New Issue