json related fn/structs to separate folder
This commit is contained in:
parent
f43d5a9b51
commit
f923e20e85
|
@ -4,19 +4,19 @@ use bellman::groth16::{prepare_verifying_key, VerifyingKey as BellmanVerifyingKe
|
|||
use pairing::{EncodedPoint, bls12_381::{Bls12, G1Uncompressed, G2Uncompressed}};
|
||||
use serde::de::{self, Visitor, Deserialize, Deserializer};
|
||||
|
||||
use pghr13_json::clean_0x;
|
||||
use json::pghr13::clean_0x;
|
||||
use Groth16VerifyingKey;
|
||||
|
||||
/// Load Sapling spend verification key.
|
||||
pub fn load_sapling_spend_verifying_key() -> Result<Groth16VerifyingKey, String> {
|
||||
let spend_vk_json = include_bytes!("../../res/sapling-spend-verifying-key.json");
|
||||
let spend_vk_json = include_bytes!("../../../res/sapling-spend-verifying-key.json");
|
||||
let spend_vk = serde_json::from_slice::<VerifyingKey>(&spend_vk_json[..]).unwrap();
|
||||
Ok(Groth16VerifyingKey(prepare_verifying_key(&spend_vk.into())))
|
||||
}
|
||||
|
||||
/// Load Sapling output verification key.
|
||||
pub fn load_sapling_output_verifying_key() -> Result<Groth16VerifyingKey, String> {
|
||||
let output_vk_json = include_bytes!("../../res/sapling-output-verifying-key.json");
|
||||
let output_vk_json = include_bytes!("../../../res/sapling-output-verifying-key.json");
|
||||
let output_vk = serde_json::from_slice::<VerifyingKey>(&output_vk_json[..]).unwrap();
|
||||
Ok(Groth16VerifyingKey(prepare_verifying_key(&output_vk.into())))
|
||||
}
|
||||
|
@ -143,13 +143,13 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn output_key() {
|
||||
let output_vk_json = include_bytes!("../../res/sapling-output-verifying-key.json");
|
||||
let output_vk_json = include_bytes!("../../../res/sapling-output-verifying-key.json");
|
||||
serde_json::from_slice::<VerifyingKey>(&output_vk_json[..]).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn spend_key() {
|
||||
let spend_vk_json = include_bytes!("../../res/sapling-spend-verifying-key.json");
|
||||
let spend_vk_json = include_bytes!("../../../res/sapling-spend-verifying-key.json");
|
||||
serde_json::from_slice::<VerifyingKey>(&spend_vk_json[..]).unwrap();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
pub mod groth16;
|
||||
pub mod pghr13;
|
|
@ -13,9 +13,8 @@ pub extern crate sapling_crypto;
|
|||
|
||||
#[macro_use] extern crate serde_derive;
|
||||
|
||||
mod groth16_json;
|
||||
mod json;
|
||||
mod pghr13;
|
||||
mod pghr13_json;
|
||||
|
||||
pub use rcrypto::digest::Digest;
|
||||
pub use blake2_rfc::blake2b::Blake2b;
|
||||
|
@ -27,7 +26,7 @@ use rcrypto::ripemd160::Ripemd160;
|
|||
use siphasher::sip::SipHasher24;
|
||||
use primitives::hash::{H32, H160, H256};
|
||||
|
||||
pub use groth16_json::{
|
||||
pub use json::groth16::{
|
||||
load_sapling_spend_verifying_key, load_sapling_output_verifying_key,
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue