Skip to content

Commit

Permalink
Merge pull request #260 from o1-labs/feature/no-shifted-scale
Browse files Browse the repository at this point in the history
Efficient scalar mul and other Scalar improvements
  • Loading branch information
mitschabaude authored Apr 16, 2024
2 parents a585a31 + a4dd716 commit ce6bf1d
Show file tree
Hide file tree
Showing 7 changed files with 89,885 additions and 89,900 deletions.
2 changes: 1 addition & 1 deletion MINA_COMMIT
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
The mina commit used to generate the backends for node and web is
88822f9ec1e329e5cd12821e0541bf070ca2c66b
dab6eb3b9529e91a9fde14563a0d3f6726f86772
179,709 changes: 89,840 additions & 89,869 deletions compiled/node_bindings/o1js_node.bc.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion compiled/node_bindings/o1js_node.bc.map

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions compiled/web_bindings/o1js_web.bc.js

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions crypto/elliptic-curve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import { Endomorphism } from './elliptic-curve-endomorphism.js';
export {
Pallas,
PallasAffine,
Vesta,
CurveParams,
GroupAffine,
Expand Down Expand Up @@ -505,6 +506,17 @@ function affineScale(g: GroupAffine, s: bigint | boolean[], p: bigint) {

type CurveAffine = ReturnType<typeof createCurveAffine>;

const PallasAffine = createCurveAffine({
name: 'Pallas',
modulus: p,
order: q,
generator: pallasGeneratorProjective,
b,
a,
endoBase: pallasEndoBase,
endoScalar: pallasEndoScalar,
});

function createCurveAffine({
name,
modulus: p,
Expand Down
9 changes: 5 additions & 4 deletions ocaml/lib/snarky_bindings.ml
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,10 @@ module Gates = struct
end

module Group = struct
let scale p (scalar_bits : Boolean.var array) =
Pickles.Step_main_inputs.Ops.scale_fast_msb_bits p
(Shifted_value scalar_bits)
let scale_fast_unpack (base : Field.t * Field.t)
(scalar : Field.t Pickles_types.Shifted_value.Type1.t) num_bits :
(Field.t * Field.t) * Boolean.var array =
Pickles.Step_main_inputs.Ops.scale_fast_unpack base scalar ~num_bits
end

module Circuit = struct
Expand Down Expand Up @@ -575,7 +576,7 @@ let snarky =

val group =
object%js
method scale = Group.scale
val scaleFastUnpack = Group.scale_fast_unpack
end

val circuit =
Expand Down
11 changes: 6 additions & 5 deletions ocaml/lib/snarky_bindings.mli
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,12 @@ val snarky :
Js.t
Js.readonly_prop
; group :
< scale :
( field Snarky_backendless.Cvar.t Tuple_lib.Double.t
-> Boolean.var array
-> Pickles.Step_main_inputs.Inner_curve.t )
Js.meth >
< scaleFastUnpack :
( Field.t * Field.t
-> Field.t Pickles_types.Shifted_value.Type1.t
-> int
-> (Field.t * Field.t) * Boolean.var array )
Js.readonly_prop >
Js.t
Js.readonly_prop
; poseidon :
Expand Down

0 comments on commit ce6bf1d

Please sign in to comment.