Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Make Gt serializable #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fields/fq12.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn frobenius_coeffs_c1(power: usize) -> Fq2 {
}
}

#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)]
#[repr(C)]
pub struct Fq12 {
c0: Fq6,
Expand Down
2 changes: 1 addition & 1 deletion src/fields/fq6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn frobenius_coeffs_c2(n: usize) -> Fq2 {
}
}

#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, RustcEncodable, RustcDecodable)]
#[repr(C)]
pub struct Fq6 {
pub c0: Fq2,
Expand Down
15 changes: 14 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl Mul<Fr> for G2 {
fn mul(self, other: Fr) -> G2 { G2(self.0 * other.0) }
}

#[derive(Copy, Clone, PartialEq, Eq)]
#[derive(Copy, Clone, PartialEq, Eq, RustcDecodable, RustcEncodable)]
#[repr(C)]
pub struct Gt(fields::Fq12);

Expand All @@ -172,6 +172,19 @@ impl Gt {
pub fn inverse(&self) -> Self { Gt(self.0.inverse().unwrap()) }
}

pub trait SerializableGt:
rustc_serialize::Encodable +
rustc_serialize::Decodable +
'static +
Copy +
Clone +
PartialEq +
Eq
{
}

impl SerializableGt for Gt {}

impl Mul<Gt> for Gt {
type Output = Gt;

Expand Down