update to a new version of ff crate with serde support
This commit is contained in:
parent
1363d02170
commit
3279e322eb
12
Cargo.toml
12
Cargo.toml
@ -2,11 +2,12 @@
|
||||
name = "pairing"
|
||||
|
||||
# Remember to change version string in README.md.
|
||||
version = "0.15.0"
|
||||
version = "0.15.1"
|
||||
authors = [
|
||||
"Sean Bowe <ewillbefull@gmail.com>",
|
||||
"Jack Grigg <jack@z.cash>",
|
||||
"Alex Vlasov <alex.m.vlasov@gmail.com>"
|
||||
"Alex Vlasov <alex.m.vlasov@gmail.com>",
|
||||
"Alex Gluchowski <alex@gluchowski.net>"
|
||||
]
|
||||
license = "MIT/Apache-2.0"
|
||||
|
||||
@ -18,7 +19,12 @@ repository = "https://github.com/matterinc/pairing"
|
||||
[dependencies]
|
||||
rand = "0.4"
|
||||
byteorder = "1"
|
||||
ff = { version = "0.4", features = ["derive"] }
|
||||
ff = { git = 'https://github.com/matterinc/ff', features = ["derive"] }
|
||||
#ff = { path = "../ff", features = ["derive"] }
|
||||
serde = "1.0.80"
|
||||
serde_derive = "1.0.80"
|
||||
serde_json = "1.0.33"
|
||||
hex = "0.3.2"
|
||||
|
||||
[features]
|
||||
unstable-features = ["expose-arith"]
|
||||
|
@ -5,7 +5,49 @@ use ff::{Field, PrimeField, PrimeFieldDecodingError, PrimeFieldRepr};
|
||||
#[PrimeFieldGenerator = "7"]
|
||||
pub struct Fr(FrRepr);
|
||||
|
||||
#[test]
|
||||
fn test_to_hex() {
|
||||
assert_eq!(Fr::one().to_hex(), "0000000000000000000000000000000000000000000000000000000000000001");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fr_from_hex() {
|
||||
let fr = Fr::from_hex("0000000000000000000000000000000000000000000000000000000000000001").unwrap();
|
||||
assert_eq!(fr, Fr::one());
|
||||
|
||||
let fr = Fr::from_hex("0x0000000000000000000000000000000000000000000000000000000000000001").unwrap();
|
||||
assert_eq!(fr, Fr::one());
|
||||
|
||||
let fr = Fr::from_hex("0x01").unwrap();
|
||||
assert_eq!(fr, Fr::one());
|
||||
|
||||
let fr = Fr::from_hex("0x00").unwrap();
|
||||
assert_eq!(fr, Fr::zero());
|
||||
|
||||
let fr = Fr::from_hex("00").unwrap();
|
||||
assert_eq!(fr, Fr::zero());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fr_serialize() {
|
||||
assert_eq!(
|
||||
serde_json::to_string(&Fr::one()).unwrap(),
|
||||
r#""0x0000000000000000000000000000000000000000000000000000000000000001""#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_fr_deserialize() {
|
||||
let json = r#""0x0000000000000000000000000000000000000000000000000000000000000001""#;
|
||||
let fr: Fr = serde_json::from_str(json).unwrap();
|
||||
assert_eq!(fr, Fr::one());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_roots_of_unity() {
|
||||
assert_eq!(Fr::S, 28);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_default() {
|
||||
assert_eq!(Fr::default(), Fr::zero());
|
||||
}
|
@ -15,6 +15,11 @@ extern crate byteorder;
|
||||
extern crate ff;
|
||||
extern crate rand;
|
||||
|
||||
extern crate hex;
|
||||
extern crate serde;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user