Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/group type #37

Merged
merged 17 commits into from Jun 2, 2020
Merged

Refactor/group type #37

merged 17 commits into from Jun 2, 2020

Conversation

collinc97
Copy link
Collaborator

Changes:

Implements: #26, #30

Syntax:

function main() {
  // Definitions
  let a = 0group;
  let b = (0, 1)group;

  // Expressions
  let c = a + b;
  let d = a - b;
  let e: bool = a == b;
  let f = if e ? a : b;
  
  // Statements
  assert_eq!(a, b);
}

Function inputs supported function main(g: group)
Function returns supported function main() -> group

Functionality:

New GroupType trait defines an affine point on the curve passed into the Leo compiler. The set of affine points on the curve defines a group.

pub trait GroupType<F: Field>:
    Sized
    + Clone
    + Debug
    + EqGadget<F>
    + ConditionalEqGadget<F>
    + AllocGadget<String, F>
    + CondSelectGadget<F>
    + ToBitsGadget<F>
    + ToBytesGadget<F>
{
    fn constant(string: String) -> Result<Self, GroupError>;

    fn add<CS: ConstraintSystem<F>>(&self, cs: CS, other: &Self) -> Result<Self, GroupError>;

    fn sub<CS: ConstraintSystem<F>>(&self, cs: CS, other: &Self) -> Result<Self, GroupError>;
}

An example implementation of GroupType can be found at /compiler/group/edwards_bls12.rs

@howardwu howardwu merged commit f546752 into master Jun 2, 2020
@collinc97 collinc97 deleted the refactor/group-type branch June 3, 2020 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants