Moving id_u and id_s from the client API to registration finish instead of start (#102)

This commit is contained in:
Kevin Lewi
2020-12-17 14:00:32 -08:00
committed by GitHub
parent 605d2b639b
commit f5b5391ee0
5 changed files with 100 additions and 130 deletions
+2 -14
View File
@@ -56,21 +56,9 @@ fn client_registration_roundtrip() {
let pw = b"hunter2";
let mut rng = OsRng;
let sc = <RistrettoPoint as Group>::random_scalar(&mut rng);
let id_u_length: usize = rng.gen_range(0, MAX_ID_LENGTH);
let id_s_length: usize = rng.gen_range(0, MAX_ID_LENGTH);
let mut id_u = [0u8; MAX_ID_LENGTH];
rng.fill_bytes(&mut id_u);
let mut id_s = [0u8; MAX_ID_LENGTH];
rng.fill_bytes(&mut id_s);
// serialization order: id_u, id_s, scalar, password
let bytes: Vec<u8> = [
&serialize(&id_u[..id_u_length], 2)[..],
&serialize(&id_s[..id_s_length], 2)[..],
&sc.as_bytes()[..],
&pw[..],
]
.concat();
// serialization order: scalar, password
let bytes: Vec<u8> = [&sc.as_bytes()[..], &pw[..]].concat();
let reg = ClientRegistration::<Default>::try_from(&bytes[..]).unwrap();
let reg_bytes = reg.to_bytes();
assert_eq!(reg_bytes, bytes);