more updates

This commit is contained in:
J. Ayo Akinyele 2018-05-06 21:50:37 -04:00
parent 9b1a3bc3a3
commit 651bd08065
5 changed files with 85 additions and 48 deletions

View File

@ -1,35 +0,0 @@
<component name="libraryTable">
<library name="Cargo &lt;libbolt&gt;">
<CLASSES>
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/num-traits-0.1.43" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/bincode-0.6.1" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/libsodium-sys-0.0.16" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/byteorder-1.2.1" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/rustc-serialize-0.3.24" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_derive_internals-0.22.1" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-x86_64-pc-windows-gnu-0.4.0" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.4.2" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-0.7.15" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/unicode-xid-0.1.0" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-0.2.3" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-0.3.4" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/bitflags-1.0.1" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/fuchsia-zircon-sys-0.3.3" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/winapi-i686-pc-windows-gnu-0.4.0" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_derive-1.0.35" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/quote-0.4.2" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.3.22" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/bn-0.4.3" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/num-traits-0.2.0" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/pkg-config-0.3.9" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/serde-1.0.27" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.36" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/bincode-0.5.9" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/fuchsia-zircon-0.3.3" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/syn-0.12.14" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/byteorder-0.5.3" />
<root url="file://$USER_HOME$/.cargo/registry/src/github.com-1ecc6299db9ec823/sodiumoxide-0.0.16" />
</CLASSES>
<SOURCES />
</library>
</component>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -259,7 +259,7 @@ The unidirectional payment construction only supports payments from a customer t
\item ${\sf Setup}(1^\lambda) \rightarrow {\sf PP}$. On input $\lambda$, optionally generate CRS parameters for (1) a secure commitment scheme (see Section~\ref{sec:commit}), (2) a non-interactive zero knowledge proof system (see Section~\ref{sec:nizkp}). Output all of these as ${\sf PP}$.
% Key generation description
${\sf KeyGen}({\sf PP}) \rightarrow (pk, sk)$.
\item ${\sf KeyGen}({\sf PP}) \rightarrow (pk, sk)$.
\begin{itemize}
\item Compute $(pk, sk) \leftarrow \prod_{\sf sig}.{\sf SigKeygen}(1^\lambda)$. %Note that $pk$ can be derived from the $sk$.
\end{itemize}
@ -275,7 +275,7 @@ ${\sf KeyGen}({\sf PP}) \rightarrow (pk, sk)$.
\end{itemize}
% Init algorithm description
${\sf Init_{M}}({\sf PP}, \BC, \BM, pk_m, sk_m) \rightarrow {\sf T}_m, csk_m$. On input a keypair $(pk_m, sk_m)$, perform the following:
\item ${\sf Init_{M}}({\sf PP}, \BC, \BM, pk_m, sk_m) \rightarrow {\sf T}_m, csk_m$. On input a keypair $(pk_m, sk_m)$, perform the following:
\begin{itemize}
\item Output ${\sf T}_m = pk_m$ and $csk_m = (sk_m, \BM)$.
@ -396,11 +396,12 @@ The bidirectional payment construction enables compact closure and compact walle
\item ${\sf Setup}(1^\lambda) \rightarrow {\sf PP}$. On input $\lambda$, optionally generate CRS parameters for (1) a secure commitment scheme (see Section~\ref{sec:commit}), (2) a non-interactive zero knowledge proof system (see Section~\ref{sec:nizkp}). Output all of these as ${\sf PP}$.
% Key generation description
${\sf KeyGen}({\sf PP}) \rightarrow (pk, sk)$.
\item ${\sf KeyGen}({\sf PP}) \rightarrow (pk, sk)$.
\begin{itemize}
\item Compute $(pk, sk) \leftarrow \prod_{\sf sig}.{\sf SigKeygen}(1^\lambda)$. %Note that $pk$ can be derived from the $sk$.
\end{itemize}
% Init algorithm for customer
\medskip \noindent
\item ${\sf Init_{C}}({\sf PP}, {\sf cID}, \BC, \BM, pk_c, sk_c) \rightarrow ({\sf T}_{C}, csk_{C})$. On input a keypair $(pk_c, sk_c)$, perform the following:
@ -412,8 +413,8 @@ ${\sf KeyGen}({\sf PP}) \rightarrow (pk, sk)$.
\item Output ${\sf T}_c = ({\sf wCom}, pk_c)$ and $csk_c = (sk_c, {\sf cID}, wpk, wsk, r, \BC)$.
\end{itemize}
% Init algorithm description
${\sf Init_{M}}({\sf PP}, \BC, \BM, pk_m, sk_m) \rightarrow {\sf T}_m, csk_m$. On input a keypair $(pk_m, sk_m)$, perform the following:
% Init algorithm description for merchant
\item ${\sf Init_{M}}({\sf PP}, \BC, \BM, pk_m, sk_m) \rightarrow {\sf T}_m, csk_m$. On input a keypair $(pk_m, sk_m)$, perform the following:
\begin{itemize}
\item Output ${\sf T}_m = pk_m$ and $csk_m = (sk_m, \BM)$.

View File

@ -125,3 +125,14 @@ pub fn verify(mpk: &PublicParams, pk: &PublicKey, m: Fr, sig: &Signature) -> boo
let rhs2 = pairing(mpk.g, sig.c);
return (lhs1 == rhs1) && (lhs2 == rhs2);
}
pub fn gen_blind(sig: &Signature) -> Signature {
let rng = &mut rand::thread_rng();
let r = Fr::random(rng);
let r1 = Fr::random(rng);
let a = sig.a * r;
let b = sig.b * r;
let c = (sig.c * r) * r1;
let bsig = Signature { a: a, b: b, c:c };
return bsig;
}

View File

@ -444,6 +444,7 @@ pub fn print(g: &G1) -> String {
////////////////////////////////// CL Sigs /////////////////////////////////////
// refund message
#[derive(Clone)]
pub struct RefundMessage<'a> {
prefix: &'a str, // string prefix for the prefix
@ -485,6 +486,32 @@ impl<'a> RefundMessage<'a> {
}
}
// spend message
#[derive(Clone)]
pub struct SpendMessage<'a> {
prefix: &'a str,
j: i32,
s: G1,
u: G1,
pi: Proof,
ck: SymKey
}
impl<'a> SpendMessage<'a> {
pub fn new(_j: i32, _s: G1, _u: G1, _pi: Proof, _ck: SymKey) -> SpendMessage<'a> {
SpendMessage {
prefix: "spend", j: _j, s: _s, u: _u, pi: _pi, ck: _ck,
}
}
pub fn hash(&self) -> Fr {
// hash into a Fr element
}
}
// coin message
////////////////////////////////// CL Sigs /////////////////////////////////////
////////////////////////////////// COMMITMENT //////////////////////////////////
@ -535,6 +562,42 @@ impl Message {
////////////////////////////////// COMMITMENT //////////////////////////////////
////////////////////////////////// NIZKP //////////////////////////////////
#[derive(Copy, Clone)]
pub struct Proof {
T: G1,
c: Fr,
s1: Fr,
s2: Fr
}
pub fn hash(g: &G1, h: &G1, X: &G1, Y: &G1, ) -> Fr {
let g_vec: Vec<u8> = encode(&g, Infinite).unwrap();
}
pub fn create_nizk_proof_one(pp: &PublicParams, pk: &PublicKey, sk: &SecretKey) -> Proof {
let rng = &mut rand::thread_rng();
let t1 = Fr::random(rng);
let t2 = Fr::random(rng);
let T = (pk.g * t1) + (pk.h * t2);
let c = hash(pp.g, pp.h, pk.X, pk.Y, T);
let s1 = (sk.x * c) + t1;
let s2 = (sk.y * c) + t2;
return Proof { T: T, c: c, s1: s1, s2: s2 };
}
pub fn verify_nizk_proof_one(proof: &Proof) -> bool {
// how do we verify the proof?
}
////////////////////////////////// NIZKP //////////////////////////////////
pub mod unidirectional {
use std::fmt;
use rand;
@ -628,16 +691,19 @@ pub mod unidirectional {
}
// TODO: requires NIZK proof system
pub fn establish_customer_send(pp: &PublicParams, t_m: &clsigs::PublicKey, csk_c: &CustSecretKey) {
pub fn establish_customer(pp: &PublicParams, t_m: &clsigs::PublicKey, csk_c: &CustSecretKey) {
println ! ("Run establish_customer algorithm...");
// set sk_0 to random bytes of length l
// let sk_0 = random_bytes(pp.l);
let buf_len: usize = pp.l_bits as usize;
let mut sk0 = vec![0; buf_len];
randombytes::randombytes_into(&mut sk0);
let pi1 = create_nizk_proof_one(csk_c.sk, csk_c.k1, csk_c.k2, );
}
pub fn estalibsh_mercahnt_send() {
// the merchant calls this method after obtaining
pub fn estalibsh_merchant() {
}