-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Garaga BN/BLS pairing interface & tests
- Loading branch information
1 parent
276c848
commit 974a8b7
Showing
9 changed files
with
1,021 additions
and
273 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from src.definitions import is_zero_mod_P, get_P | ||
from src.precompiled_circuits.ec import get_IS_ON_CURVE_G1_G2_circuit | ||
from src.modulo_circuit import run_modulo_circuit, ModuloCircuit | ||
from starkware.cairo.common.cairo_builtins import ModBuiltin, UInt384 | ||
|
||
func is_on_curve_g1_g2{ | ||
range_check_ptr, range_check96_ptr: felt*, add_mod_ptr: ModBuiltin*, mul_mod_ptr: ModBuiltin* | ||
}(curve_id: felt, input: felt*) -> (res: felt) { | ||
alloc_locals; | ||
let (P) = get_P(curve_id); | ||
|
||
let (circuit) = get_IS_ON_CURVE_G1_G2_circuit(curve_id); | ||
let (output: felt*) = run_modulo_circuit(circuit, input); | ||
let (check_g1: felt) = is_zero_mod_P([cast(output, UInt384*)], P); | ||
let (check_g20: felt) = is_zero_mod_P([cast(output + UInt384.SIZE, UInt384*)], P); | ||
let (check_g21: felt) = is_zero_mod_P([cast(output + 2 * UInt384.SIZE, UInt384*)], P); | ||
|
||
if (check_g1 == 0) { | ||
return (res=0); | ||
} | ||
if (check_g20 == 0) { | ||
return (res=0); | ||
} | ||
if (check_g21 == 0) { | ||
return (res=0); | ||
} | ||
return (res=1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.