Update SecretKey to 32 bytes (#1072)
* Update SecretKey to 32 bytes Signed-off-by: Kirk Baird <baird.k@outlook.com> * Stop test from padding to 48 bytes Signed-off-by: Kirk Baird <baird.k@outlook.com> * Fix keypair file secret key length Signed-off-by: Kirk Baird <baird.k@outlook.com>
This commit is contained in:
parent
1abb54dabd
commit
c102d9d1f9
16
Cargo.lock
generated
16
Cargo.lock
generated
@ -82,7 +82,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "amcl"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/sigp/milagro_bls?tag=v1.0.0#ac3e5c3a48aed7ea810ac411655963f5177430b7"
|
||||
source = "git+https://github.com/sigp/milagro_bls?tag=v1.0.1#2ccdd4b517c1ab3debe10277deed9d1b1cbbe9ce"
|
||||
dependencies = [
|
||||
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -370,7 +370,7 @@ dependencies = [
|
||||
"eth2_ssz 0.1.2",
|
||||
"eth2_ssz_types 0.2.0",
|
||||
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"milagro_bls 1.0.0 (git+https://github.com/sigp/milagro_bls?tag=v1.0.0)",
|
||||
"milagro_bls 1.0.1 (git+https://github.com/sigp/milagro_bls?tag=v1.0.1)",
|
||||
"rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -1185,7 +1185,7 @@ dependencies = [
|
||||
"eth2_hashing 0.1.1",
|
||||
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"milagro_bls 1.0.0 (git+https://github.com/sigp/milagro_bls?tag=v1.0.0)",
|
||||
"milagro_bls 1.0.1 (git+https://github.com/sigp/milagro_bls?tag=v1.0.1)",
|
||||
"num-bigint 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_derive 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -2524,10 +2524,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "milagro_bls"
|
||||
version = "1.0.0"
|
||||
source = "git+https://github.com/sigp/milagro_bls?tag=v1.0.0#ac3e5c3a48aed7ea810ac411655963f5177430b7"
|
||||
version = "1.0.1"
|
||||
source = "git+https://github.com/sigp/milagro_bls?tag=v1.0.1#2ccdd4b517c1ab3debe10277deed9d1b1cbbe9ce"
|
||||
dependencies = [
|
||||
"amcl 0.2.0 (git+https://github.com/sigp/milagro_bls?tag=v1.0.0)",
|
||||
"amcl 0.2.0 (git+https://github.com/sigp/milagro_bls?tag=v1.0.1)",
|
||||
"hex 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
@ -5186,7 +5186,7 @@ dependencies = [
|
||||
"checksum aesni 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2f70a6b5f971e473091ab7cfb5ffac6cde81666c4556751d8d5620ead8abf100"
|
||||
"checksum ahash 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "6f33b5018f120946c1dcf279194f238a9f146725593ead1c08fa47ff22b0b5d3"
|
||||
"checksum aho-corasick 0.7.10 (registry+https://github.com/rust-lang/crates.io-index)" = "8716408b8bc624ed7f65d223ddb9ac2d044c0547b6fa4b0d554f3a9540496ada"
|
||||
"checksum amcl 0.2.0 (git+https://github.com/sigp/milagro_bls?tag=v1.0.0)" = "<none>"
|
||||
"checksum amcl 0.2.0 (git+https://github.com/sigp/milagro_bls?tag=v1.0.1)" = "<none>"
|
||||
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
|
||||
"checksum arc-swap 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d663a8e9a99154b5fb793032533f6328da35e23aac63d5c152279aa8ba356825"
|
||||
"checksum arrayref 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544"
|
||||
@ -5381,7 +5381,7 @@ dependencies = [
|
||||
"checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00"
|
||||
"checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400"
|
||||
"checksum memoffset 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b4fc2c02a7e374099d4ee95a193111f72d2110197fe200272371758f6c3643d8"
|
||||
"checksum milagro_bls 1.0.0 (git+https://github.com/sigp/milagro_bls?tag=v1.0.0)" = "<none>"
|
||||
"checksum milagro_bls 1.0.1 (git+https://github.com/sigp/milagro_bls?tag=v1.0.1)" = "<none>"
|
||||
"checksum mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0"
|
||||
"checksum mime 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
|
||||
"checksum mime_guess 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212"
|
||||
|
@ -5,7 +5,7 @@ use std::io::{Error, ErrorKind, Read, Write};
|
||||
use std::path::Path;
|
||||
|
||||
pub const PUBLIC_KEY_BYTES_LEN: usize = 96;
|
||||
pub const SECRET_KEY_BYTES_LEN: usize = 48;
|
||||
pub const SECRET_KEY_BYTES_LEN: usize = 32;
|
||||
|
||||
pub const BATCH_SIZE: usize = 1_000; // ~15MB
|
||||
|
||||
|
@ -5,7 +5,7 @@ authors = ["Paul Hauner <paul@paulhauner.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
milagro_bls = { git = "https://github.com/sigp/milagro_bls", tag = "v1.0.0" }
|
||||
milagro_bls = { git = "https://github.com/sigp/milagro_bls", tag = "v1.0.1" }
|
||||
eth2_hashing = "0.1.0"
|
||||
hex = "0.3"
|
||||
rand = "0.7.2"
|
||||
|
@ -56,7 +56,7 @@ mod reals {
|
||||
|
||||
pub const BLS_AGG_SIG_BYTE_SIZE: usize = 96;
|
||||
pub const BLS_SIG_BYTE_SIZE: usize = 96;
|
||||
pub const BLS_SECRET_KEY_BYTE_SIZE: usize = 48;
|
||||
pub const BLS_SECRET_KEY_BYTE_SIZE: usize = 32;
|
||||
pub const BLS_PUBLIC_KEY_BYTE_SIZE: usize = 48;
|
||||
|
||||
use eth2_hashing::hash;
|
||||
|
@ -80,9 +80,8 @@ mod tests {
|
||||
#[test]
|
||||
pub fn test_ssz_round_trip() {
|
||||
let byte_key = [
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 70, 211, 210, 129, 231, 69, 162, 234,
|
||||
16, 15, 244, 214, 126, 201, 0, 85, 28, 239, 82, 121, 208, 190, 223, 6, 169, 202, 86,
|
||||
236, 197, 218, 3, 69,
|
||||
3, 211, 210, 129, 231, 69, 162, 234, 16, 15, 244, 214, 126, 201, 0, 85, 28, 239, 82,
|
||||
121, 208, 190, 223, 6, 169, 202, 86, 236, 197, 218, 3, 69,
|
||||
];
|
||||
let original = SecretKey::from_bytes(&byte_key).unwrap();
|
||||
|
||||
|
@ -11,7 +11,7 @@ lazy_static = "1.4.0"
|
||||
num-bigint = "0.2.3"
|
||||
eth2_hashing = "0.1.0"
|
||||
hex = "0.3"
|
||||
milagro_bls = { git = "https://github.com/sigp/milagro_bls", tag = "v1.0.0" }
|
||||
milagro_bls = { git = "https://github.com/sigp/milagro_bls", tag = "v1.0.1" }
|
||||
serde_yaml = "0.8.11"
|
||||
serde = "1.0.102"
|
||||
serde_derive = "1.0.102"
|
||||
|
@ -27,7 +27,7 @@ use std::convert::TryInto;
|
||||
use std::fs::File;
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub const PRIVATE_KEY_BYTES: usize = 48;
|
||||
pub const PRIVATE_KEY_BYTES: usize = 32;
|
||||
pub const PUBLIC_KEY_BYTES: usize = 48;
|
||||
pub const HASH_BYTES: usize = 32;
|
||||
|
||||
|
@ -23,7 +23,6 @@ impl Case for BlsSign {
|
||||
// Convert private_key and message to required types
|
||||
let mut sk = hex::decode(&self.input.privkey[2..])
|
||||
.map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))?;
|
||||
pad_to_48(&mut sk);
|
||||
let sk = SecretKey::from_bytes(&sk).unwrap();
|
||||
let msg = hex::decode(&self.input.message[2..])
|
||||
.map_err(|e| Error::FailedToParseTest(format!("{:?}", e)))?;
|
||||
@ -37,10 +36,3 @@ impl Case for BlsSign {
|
||||
compare_result::<Vec<u8>, Vec<u8>>(&Ok(signature.as_bytes()), &Some(decoded))
|
||||
}
|
||||
}
|
||||
|
||||
// Increase the size of an array to 48 bytes
|
||||
fn pad_to_48(array: &mut Vec<u8>) {
|
||||
while array.len() < 48 {
|
||||
array.insert(0, 0);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user