-
Notifications
You must be signed in to change notification settings - Fork 1.7k
EIP-212 (bn128 curve pairing) #5307
Conversation
for reference ethereum/EIPs#212 |
@arkpar |
ethcore/src/builtin.rs
Outdated
@@ -191,6 +192,9 @@ struct Bn128AddImpl; | |||
#[derive(Debug)] | |||
struct Bn128MulImpl; | |||
|
|||
#[derive(Debug)] | |||
struct Bn128ParingImpl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: "Paring"
fn execute(&self, input: &[u8], output: &mut BytesRef) -> Result<(), Error> { | ||
use bn::{AffineG1, AffineG2, Fq, Fq2, pairing, G1, G2, Gt}; | ||
|
||
let elements = input.len() / 192; // (a, b_a, b_b - each 64-byte affine coordinates) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the input for builtins supposed to be infinitely zero-extended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this builtin, no.
Could you give a summary of changes to the "bn" library? |
no new logic, just some internal api exposed, which will allow
|
ethcore/src/builtin.rs
Outdated
@@ -713,7 +815,82 @@ mod tests { | |||
assert!(res.is_err(), "There should be built-in error here"); | |||
} | |||
} | |||
|
|||
fn builitin_pairing() -> Builtin { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: builitin
).expect("Generator P1(1, 2) is a valid curve point")); | ||
} | ||
|
||
lazy_static! { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these 3 lazy_static
invocations could be combined. These are generators for alt_bn128
, right? Eventually it would be nice to have these extracted to constants in a bn::alt_gen
module, but not a blocker for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep sounds good
goes after #4999