Add function generating the payinfo

This commit is contained in:
aniampio
2023-10-24 14:49:56 +01:00
parent 5b66701c5d
commit 4a54fd93f6
4 changed files with 23 additions and 1 deletions
Vendored
BIN
View File
Binary file not shown.
Generated
+1
View File
@@ -3138,6 +3138,7 @@ version = "0.1.0"
dependencies = [
"bls12_381 0.6.0",
"bs58",
"chrono",
"criterion",
"digest 0.9.0",
"ff 0.11.0",
@@ -7,6 +7,7 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
chrono = "0.4.19"
#bls12_381 = { version = "0.5", default-features = false, features = ["pairings", "alloc", "experimental"] }
bls12_381 = { path = "/Users/ania/Documents/Git/andrew_bls12_381", default-features = false, features = ["alloc", "pairings", "experimental", "zeroize"] }
itertools = "0.10"
@@ -6,12 +6,14 @@ use group::Curve;
use crate::Attribute;
use crate::error::{CompactEcashError, Result};
use crate::proofs::proof_spend::{SpendInstance, SpendProof, SpendWitness};
use crate::scheme::keygen::{SecretKeyUser, VerificationKeyAuth};
use crate::scheme::keygen::{SecretKeyUser, VerificationKeyAuth, PublicKeyUser};
use crate::scheme::setup::{GroupParameters, Parameters};
use crate::utils::{
check_bilinear_pairing, hash_to_scalar, Signature, SignerIndex,
try_deserialize_g1_projective, try_deserialize_scalar, try_deserialize_g2_projective,
};
use chrono::{Utc, Timelike};
use rand::{Rng, thread_rng};
pub mod aggregation;
pub mod identify;
@@ -312,6 +314,24 @@ pub struct PayInfo {
pub info: [u8; 32],
}
pub fn generate_payinfo(provider_pk: PublicKeyUser) -> Vec<u8>{
let mut rng = thread_rng();
let mut rbytes = [0u8; 32];
rng.fill(&mut rbytes);
let timestamp = Utc::now().timestamp();
let timestamp_bytes: [u8; 8] = timestamp.to_be_bytes();
let ppk_bytes = provider_pk.pk.to_affine().to_compressed();
let mut payinfo = Vec::with_capacity(32 + 8 +48);
payinfo.extend_from_slice(&rbytes);
payinfo.extend_from_slice(&timestamp_bytes);
payinfo.extend_from_slice(&ppk_bytes);
payinfo
}
#[derive(Debug, Clone, PartialEq)]
pub struct Payment {
pub kappa: G2Projective,