-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
After implementing Rescue, I benchmarked it and found it was really slow ``` ┌─────────────────────────────────────────────┬────────────┬──────────┬──────────┬──────────┬────────────┐ │ Name │ Time/Run │ mWd/Run │ mjWd/Run │ Prom/Run │ Percentage │ ├─────────────────────────────────────────────┼────────────┼──────────┼──────────┼──────────┼────────────┤ │ [lib/snark_params/snark_params.ml] pedersen │ 152.88us │ 22.56kw │ 1.32kw │ 1.32kw │ 5.10% │ │ [lib/snark_params/snark_params.ml] rescue │ 2_995.88us │ 120.05kw │ 118.56kw │ 118.56kw │ 100.00% │ │ [lib/snark_params/snark_params.ml] poseidon │ 132.82us │ 6.03kw │ 4.71kw │ 4.71kw │ 4.43% │ └─────────────────────────────────────────────┴────────────┴──────────┴──────────┴──────────┴────────────┘ ``` but as you can see from that table, the [Poseidon](https://eprint.iacr.org/2019/458.pdf) implementation in this PR is way faster! I'm not 100% sure about the number of rounds I chose. It may need to be a bit higher.
- Loading branch information
Showing
12 changed files
with
571 additions
and
72 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
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
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
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
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
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,45 @@ | ||
module type Field = sig | ||
type t | ||
|
||
val zero : t | ||
|
||
val ( * ) : t -> t -> t | ||
|
||
val ( + ) : t -> t -> t | ||
end | ||
|
||
module type Operations = sig | ||
module Field : Field | ||
|
||
val add_block : state:Field.t array -> Field.t array -> unit | ||
|
||
val apply_matrix : Field.t array array -> Field.t array -> Field.t array | ||
|
||
val copy : Field.t array -> Field.t array | ||
end | ||
|
||
module Inputs = struct | ||
module type Common = sig | ||
module Field : Field | ||
|
||
val to_the_alpha : Field.t -> Field.t | ||
|
||
module Operations : Operations with module Field := Field | ||
end | ||
|
||
module type Rescue = sig | ||
include Common | ||
|
||
val alphath_root : Field.t -> Field.t | ||
end | ||
end | ||
|
||
module type Permutation = sig | ||
module Field : Field | ||
|
||
val add_block : state:Field.t array -> Field.t array -> unit | ||
|
||
val copy : Field.t array -> Field.t array | ||
|
||
val block_cipher : Field.t Params.t -> Field.t array -> Field.t array | ||
end |
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,8 @@ | ||
open Core_kernel | ||
|
||
type 'a t = {mds: 'a array array; round_constants: 'a array array} | ||
[@@deriving bin_io] | ||
|
||
let map {mds; round_constants} ~f = | ||
let f = Array.map ~f:(Array.map ~f) in | ||
{mds= f mds; round_constants= f round_constants} |
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
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
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
File renamed without changes.