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

feat: add NIF to use KZG functions #780

Merged
merged 54 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
eac1b66
Fix spec-test runner command
Godspower-Eze Dec 12, 2023
4013dfe
Merge branch 'lambdaclass:main' into main
Godspower-Eze Dec 13, 2023
838c782
Merge branch 'main' of github.com:Godspower-Eze/lambda_ethereum_conse…
Godspower-Eze Dec 14, 2023
2ea4f10
Merge branch 'main' of github.com:Godspower-Eze/lambda_ethereum_conse…
Godspower-Eze Dec 14, 2023
8b29cf4
Merge branch 'main' of github.com:Godspower-Eze/lambda_ethereum_conse…
Godspower-Eze Jan 12, 2024
65e32dc
Merge branch 'main' of github.com:Godspower-Eze/lambda_ethereum_conse…
Godspower-Eze Jan 14, 2024
c0407e5
Merge branch 'main' of github.com:Godspower-Eze/lambda_ethereum_conse…
Godspower-Eze Jan 16, 2024
3a91893
feat: added boilerplate for merkleization benchmark
Godspower-Eze Jan 17, 2024
0073c8b
Merge branch 'main' into #issue597
Godspower-Eze Jan 19, 2024
74e73b4
update
Godspower-Eze Jan 19, 2024
b324445
update
Godspower-Eze Jan 22, 2024
579ef94
Merge branch 'main' into #issue597
Godspower-Eze Jan 22, 2024
3bae020
update
Godspower-Eze Jan 23, 2024
bed96e9
Merge branch '#issue597' of github.com:Godspower-Eze/lambda_ethereum_…
Godspower-Eze Jan 23, 2024
d6a390d
Merge branch 'main' into #issue597
Godspower-Eze Jan 23, 2024
143cca1
update
Godspower-Eze Jan 24, 2024
bad2c97
Merge branch 'main' into #issue597
Godspower-Eze Jan 24, 2024
77013de
Merge branch '#issue597' of github.com:Godspower-Eze/lambda_ethereum_…
Godspower-Eze Jan 24, 2024
208e62c
update
Godspower-Eze Jan 24, 2024
755b740
update
Godspower-Eze Jan 24, 2024
fe46df3
update
Godspower-Eze Jan 25, 2024
4c91091
update
Godspower-Eze Jan 25, 2024
028c9f2
Merge branch 'main' into #issue597
Godspower-Eze Jan 25, 2024
9ed34f6
update
Godspower-Eze Jan 28, 2024
92f061a
update
Godspower-Eze Jan 28, 2024
82ca523
Merge branch 'main' into #issue597
Godspower-Eze Jan 28, 2024
5a5f29d
Merge branch '#issue597' of github.com:Godspower-Eze/lambda_ethereum_…
Godspower-Eze Jan 28, 2024
8ded18e
update
Godspower-Eze Jan 28, 2024
938c4be
update
Godspower-Eze Jan 28, 2024
70219b9
update
Godspower-Eze Jan 29, 2024
eb1a6b2
update
Godspower-Eze Jan 29, 2024
31d5345
Merge branch 'main' of github.com:Godspower-Eze/lambda_ethereum_conse…
Godspower-Eze Jan 29, 2024
f572371
update
Godspower-Eze Jan 29, 2024
5c5706b
Merge branch '#issue597'
Godspower-Eze Jan 29, 2024
9fb757a
Merge branch 'lambdaclass:main' into main
Godspower-Eze Jan 30, 2024
dd8ab54
Merge branch 'lambdaclass:main' into main
Godspower-Eze Feb 1, 2024
17687e2
Merge branch 'main' of github.com:Godspower-Eze/lambda_ethereum_conse…
Godspower-Eze Feb 6, 2024
70f6540
Merge branch 'main' of github.com:Godspower-Eze/lambda_ethereum_conse…
Godspower-Eze Feb 7, 2024
fb0b129
Merge branch 'main' of github.com:Godspower-Eze/lambda_ethereum_conse…
Godspower-Eze Feb 14, 2024
8a091a6
Merge branch 'main' of github.com:Godspower-Eze/lambda_ethereum_conse…
Godspower-Eze Feb 14, 2024
9d740fd
feat: init
Godspower-Eze Feb 15, 2024
e85022b
Merge branch 'main' of github.com:Godspower-Eze/lambda_ethereum_conse…
Godspower-Eze Feb 15, 2024
7577fbc
Merge branch 'main' of github.com:Godspower-Eze/lambda_ethereum_conse…
Godspower-Eze Feb 15, 2024
911c86b
Merge branch 'main' into nif-kzg
Godspower-Eze Feb 15, 2024
f4b6b58
feat: boilerplate and initial setup
Godspower-Eze Feb 19, 2024
a40d35b
Merge branch 'main' into nif-kzg
Godspower-Eze Feb 19, 2024
fa9e732
Merge branch 'main' into nif-kzg
Godspower-Eze Feb 22, 2024
c384404
feat: implemented all functions
Godspower-Eze Feb 23, 2024
d14aa57
feat: update typings
Godspower-Eze Feb 26, 2024
b179a04
feat: update typings
Godspower-Eze Feb 26, 2024
63477bd
Merge branch 'main' into nif-kzg
Godspower-Eze Mar 6, 2024
3054160
Update native/kzg_nif/Cargo.toml
Godspower-Eze Mar 6, 2024
0b353d8
feat: updated to use version
Godspower-Eze Mar 6, 2024
d5a4ea0
Update native/kzg_nif/src/lib.rs
Godspower-Eze Mar 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions lib/kzg.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
defmodule Kzg do
@moduledoc """
KZG functions
"""
use Rustler, otp_app: :lambda_ethereum_consensus, crate: "kzg_nif"

@spec blob_to_kzg_commitment(Types.blob()) :: {:ok, Types.kzg_commitment()} | {:error, binary()}
def blob_to_kzg_commitment(_blob) do
:erlang.nif_error(:nif_not_loaded)
end

@spec compute_kzg_proof(Types.blob(), Types.bytes32()) ::
{:ok, {Types.kzg_proof(), Types.bytes32()}} | {:error, binary()}
def compute_kzg_proof(_blob, _z) do
:erlang.nif_error(:nif_not_loaded)
end

@spec verify_kzg_proof(
Types.kzg_commitment(),
Types.bytes32(),
Types.bytes32(),
Types.kzg_proof()
) ::
{:ok, boolean} | {:error, binary()}
def verify_kzg_proof(_kzg_commitment, _z, _y, _kzg_proof) do
:erlang.nif_error(:nif_not_loaded)
end

@spec compute_blob_kzg_proof(Types.blob(), Types.kzg_commitment()) ::
{:ok, Types.kzg_proof()} | {:error, binary()}
def compute_blob_kzg_proof(_blob, _kzg_commitment) do
:erlang.nif_error(:nif_not_loaded)
end

@spec verify_blob_kzg_proof(Types.blob(), Types.kzg_commitment(), Types.kzg_proof()) ::
{:ok, boolean} | {:error, binary()}
def verify_blob_kzg_proof(_blob, _kzg_commitment, _kzg_proof) do
:erlang.nif_error(:nif_not_loaded)
end

@spec verify_blob_kzg_proof_batch(
list(Types.blob()),
list(Types.kzg_commitment()),
list(Types.kzg_proof())
) ::
{:ok, boolean} | {:error, binary()}
def verify_blob_kzg_proof_batch(_blobs, _kzg_commitments, _kzg_proofs) do
:erlang.nif_error(:nif_not_loaded)
end
end
4 changes: 4 additions & 0 deletions lib/types/mod.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,8 @@ defmodule Types do
@type execution_address :: bytes20
@type withdrawal_index :: uint64
@type payload_id :: bytes8
@type kzg_commitment :: bytes48
@type kzg_proof :: bytes48
## 131072 is FIELD_ELEMENTS_PER_BLOB(i.e 4096) * BYTES_PER_FIELD_ELEMENT(i.e 32)
@type blob :: <<_::131_072>>
MegaRedHand marked this conversation as resolved.
Show resolved Hide resolved
end
5 changes: 5 additions & 0 deletions native/kzg_nif/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[target.'cfg(target_os = "macos")']
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
1 change: 1 addition & 0 deletions native/kzg_nif/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
Loading
Loading