Skip to main content

pixel_sig/
lib.rs

1#![allow(non_snake_case)]
2
3extern crate rand;
4#[macro_use]
5extern crate amcl_wrapper;
6
7use amcl_wrapper::extension_field_gt::GT;
8
9#[cfg(all(feature = "VerkeyG1", feature = "VerkeyG2"))]
10compile_error!("features `VerkeyG1` and `VerkeyG2` are mutually exclusive");
11
12// For feature VerkeyG2, verification key is in G2 and all but one element of signature are in G1
13#[cfg(feature = "VerkeyG2")]
14pub type SignatureGroup = amcl_wrapper::group_elem_g1::G1;
15#[cfg(feature = "VerkeyG2")]
16pub type SignatureGroupVec = amcl_wrapper::group_elem_g1::G1Vector;
17#[cfg(feature = "VerkeyG2")]
18pub type VerkeyGroup = amcl_wrapper::group_elem_g2::G2;
19#[cfg(feature = "VerkeyG2")]
20pub type VerkeyGroupVec = amcl_wrapper::group_elem_g2::G2Vector;
21#[cfg(feature = "VerkeyG2")]
22pub fn ate_2_pairing(
23    g1: &SignatureGroup,
24    g2: &VerkeyGroup,
25    h1: &SignatureGroup,
26    h2: &VerkeyGroup,
27) -> GT {
28    GT::ate_2_pairing(g1, g2, h1, h2)
29}
30#[cfg(feature = "VerkeyG2")]
31pub fn ate_multi_pairing(elems: Vec<(&SignatureGroup, &VerkeyGroup)>) -> GT {
32    GT::ate_multi_pairing(elems)
33}
34
35// For feature VerkeyG1, verification key is in G1 and all but one element of signature are in G2
36#[cfg(feature = "VerkeyG1")]
37pub type SignatureGroup = amcl_wrapper::group_elem_g2::G2;
38#[cfg(feature = "VerkeyG1")]
39pub type SignatureGroupVec = amcl_wrapper::group_elem_g2::G2Vector;
40#[cfg(feature = "VerkeyG1")]
41pub type VerkeyGroup = amcl_wrapper::group_elem_g1::G1;
42#[cfg(feature = "VerkeyG1")]
43pub type VerkeyGroupVec = amcl_wrapper::group_elem_g1::G1Vector;
44#[cfg(feature = "VerkeyG1")]
45pub fn ate_2_pairing(
46    g1: &SignatureGroup,
47    g2: &VerkeyGroup,
48    h1: &SignatureGroup,
49    h2: &VerkeyGroup,
50) -> GT {
51    GT::ate_2_pairing(g2, g1, h2, h1)
52}
53#[cfg(feature = "VerkeyG1")]
54pub fn ate_multi_pairing(elems: Vec<(&SignatureGroup, &VerkeyGroup)>) -> GT {
55    GT::ate_multi_pairing(
56        elems
57            .into_iter()
58            .map(|(s, v)| (v, s))
59            .collect::<Vec<(&VerkeyGroup, &SignatureGroup)>>(),
60    )
61}
62
63#[macro_use]
64extern crate failure;
65
66extern crate serde;
67#[macro_use]
68extern crate serde_derive;
69
70pub mod errors;
71pub mod keys;
72pub mod signature;
73pub mod util;
74pub mod threshold_sig;
75
76// TODO: Add a high level object that orchestrates key update and signing. Like if the signing has to
77// be done for t=x and current time in SigkeyManager is y<x, it should update time to t=x.