Skip to content

Commit 88430f4

Browse files
committed
Fix Rustler binary deserialization.
1 parent f22f688 commit 88430f4

33 files changed

+231
-224
lines changed

Cargo.lock

Lines changed: 18 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/arm/arm.ex

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
defmodule AnomaSDK.Arm do
1+
defmodule Anoma.Arm do
22
@moduledoc """
33
I define a few functions to test the ARM repo NIF interface.
44
"""
@@ -7,15 +7,15 @@ defmodule AnomaSDK.Arm do
77
otp_app: :anoma_sdk,
88
crate: :arm_bindings
99

10-
alias AnomaSDK.Arm.ComplianceInstance
11-
alias AnomaSDK.Arm.ComplianceUnit
12-
alias AnomaSDK.Arm.ComplianceWitness
13-
alias AnomaSDK.Arm.DeltaProof
14-
alias AnomaSDK.Arm.DeltaWitness
15-
alias AnomaSDK.Arm.Keypair
16-
alias AnomaSDK.Arm.LogicVerifier
17-
alias AnomaSDK.Arm.LogicVerifierInputs
18-
alias AnomaSDK.Arm.Transaction
10+
alias Anoma.Arm.ComplianceInstance
11+
alias Anoma.Arm.ComplianceUnit
12+
alias Anoma.Arm.ComplianceWitness
13+
alias Anoma.Arm.DeltaProof
14+
alias Anoma.Arm.DeltaWitness
15+
alias Anoma.Arm.Keypair
16+
alias Anoma.Arm.LogicVerifier
17+
alias Anoma.Arm.LogicVerifierInputs
18+
alias Anoma.Arm.Transaction
1919

2020
@doc """
2121
Generates a random private key (Scalar) and its corresponding public key (ProjectivePoint)

lib/arm/arm_test.ex

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,27 @@
1-
defmodule AnomaSDK.Arm.Test do
1+
defmodule Anoma.Arm.Test do
22
@moduledoc """
33
I define a few functions to test the ARM repo NIF interface.
44
"""
55

6-
mix_config = Mix.Project.config()
7-
version = mix_config[:version]
8-
github_url = mix_config[:package][:links]["GitHub"]
9-
10-
use RustlerPrecompiled,
6+
use Rustler,
117
otp_app: :anoma_sdk,
12-
crate: :arm_bindings_test,
13-
base_url: "#{github_url}/releases/download/v#{version}",
14-
version: version,
15-
force_build: System.get_env("BUILD_NATIVE") in ["1", "true"]
16-
17-
alias AnomaSDK.Arm.Action
18-
alias AnomaSDK.Arm.AppData
19-
alias AnomaSDK.Arm.Ciphertext
20-
alias AnomaSDK.Arm.ComplianceInstance
21-
alias AnomaSDK.Arm.ComplianceUnit
22-
alias AnomaSDK.Arm.ComplianceWitness
23-
alias AnomaSDK.Arm.DeltaProof
24-
alias AnomaSDK.Arm.DeltaWitness
25-
alias AnomaSDK.Arm.ExpirableBlob
26-
alias AnomaSDK.Arm.LogicVerifier
27-
alias AnomaSDK.Arm.LogicVerifierInputs
28-
alias AnomaSDK.Arm.MerklePath
29-
alias AnomaSDK.Arm.MerkleTree
30-
alias AnomaSDK.Arm.Resource
31-
alias AnomaSDK.Arm.Transaction
8+
crate: :arm_bindings_test
9+
10+
alias Anoma.Arm.Action
11+
alias Anoma.Arm.AppData
12+
alias Anoma.Arm.Ciphertext
13+
alias Anoma.Arm.ComplianceInstance
14+
alias Anoma.Arm.ComplianceUnit
15+
alias Anoma.Arm.ComplianceWitness
16+
alias Anoma.Arm.DeltaProof
17+
alias Anoma.Arm.DeltaWitness
18+
alias Anoma.Arm.ExpirableBlob
19+
alias Anoma.Arm.LogicVerifier
20+
alias Anoma.Arm.LogicVerifierInputs
21+
alias Anoma.Arm.MerklePath
22+
alias Anoma.Arm.MerkleTree
23+
alias Anoma.Arm.Resource
24+
alias Anoma.Arm.Transaction
3225

3326
# ----------------------------------------------------------------------------#
3427
# SecretKey #

lib/arm/constants.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
defmodule AnomaSDK.Arm.Constants do
1+
defmodule Anoma.Arm.Constants do
22
@moduledoc """
33
I define a list of constants used in the Anoma resource machine.
44
"""

lib/arm/datastructures/action.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
defmodule AnomaSDK.Arm.Action do
1+
defmodule Anoma.Arm.Action do
22
@moduledoc """
33
I define the datastructure `Action` that defines the structure of an action
44
for the resource machine.
55
"""
66
use TypedStruct
77

8-
alias AnomaSDK.Arm.Action
9-
alias AnomaSDK.Arm.ComplianceUnit
10-
alias AnomaSDK.Arm.LogicVerifierInputs
8+
alias Anoma.Arm.Action
9+
alias Anoma.Arm.ComplianceUnit
10+
alias Anoma.Arm.LogicVerifierInputs
1111

1212
typedstruct do
1313
@derive Jason.Encoder

lib/arm/datastructures/app_data.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
defmodule AnomaSDK.Arm.AppData do
1+
defmodule Anoma.Arm.AppData do
22
@moduledoc """
33
I define the datastructure `AppData` that defines the structure of an app data
44
for the resource machine.
55
"""
66
use TypedStruct
77

8-
alias AnomaSDK.Arm.AppData
9-
alias AnomaSDK.Arm.ExpirableBlob
8+
alias Anoma.Arm.AppData
9+
alias Anoma.Arm.ExpirableBlob
1010

1111
typedstruct do
1212
@derive Jason.Encoder

lib/arm/datastructures/cipher_text.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
defmodule AnomaSDK.Arm.Ciphertext do
1+
defmodule Anoma.Arm.Ciphertext do
22
@moduledoc """
33
Defines the type for a Ciphertext, which is just a binary.
44
"""

lib/arm/datastructures/compliance_instance.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
defmodule AnomaSDK.Arm.ComplianceInstance do
1+
defmodule Anoma.Arm.ComplianceInstance do
22
@moduledoc """
33
I define the datastructure `ComplianceInstance` that defines the structure of
44
a compliance instance for the resource machine.
55
"""
66
use TypedStruct
7-
use AnomaSDK.Arm.Inspect
8-
alias AnomaSDK.Arm.ComplianceInstance
7+
use Anoma.Arm.Inspect
8+
alias Anoma.Arm.ComplianceInstance
99

1010
typedstruct do
1111
field :consumed_nullifier, binary()
@@ -30,6 +30,6 @@ defmodule AnomaSDK.Arm.ComplianceInstance do
3030

3131
@spec from_map(map) :: t()
3232
def from_map(map) do
33-
struct(ComplianceInstance, AnomaSDK.Json.decode_keys(map))
33+
struct(ComplianceInstance, Anoma.Json.decode_keys(map))
3434
end
3535
end

lib/arm/datastructures/compliance_unit.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
defmodule AnomaSDK.Arm.ComplianceUnit do
1+
defmodule Anoma.Arm.ComplianceUnit do
22
@moduledoc """
33
I define the datastructure `ComplianceUnit` that defines the structure of a compliance unit for the resource machine.
44
"""
55
use TypedStruct
6-
alias AnomaSDK.Arm
7-
alias AnomaSDK.Arm.ComplianceInstance
8-
alias AnomaSDK.Arm.ComplianceUnit
6+
alias Anoma.Arm
7+
alias Anoma.Arm.ComplianceInstance
8+
alias Anoma.Arm.ComplianceUnit
99

1010
typedstruct do
1111
field :instance, binary()
1212
field :proof, binary()
1313
end
1414

15-
defimpl Jason.Encoder, for: AnomaSDK.Arm.ComplianceUnit do
15+
defimpl Jason.Encoder, for: Anoma.Arm.ComplianceUnit do
1616
@spec encode(struct(), term()) :: term()
1717
def encode(struct, opts) do
1818
struct
@@ -25,7 +25,7 @@ defmodule AnomaSDK.Arm.ComplianceUnit do
2525

2626
@spec from_map(map) :: t()
2727
def from_map(map) do
28-
struct(ComplianceUnit, AnomaSDK.Json.decode_keys(map))
28+
struct(ComplianceUnit, Anoma.Json.decode_keys(map))
2929
end
3030

3131
@doc """

lib/arm/datastructures/compliance_witness.ex

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
defmodule AnomaSDK.Arm.ComplianceWitness do
1+
defmodule Anoma.Arm.ComplianceWitness do
22
@moduledoc """
33
I define the datastructure `DeltaWitness` that defines the structure of a delta witness for the resource machine.
44
"""
55
use TypedStruct
66

7-
alias AnomaSDK.Arm.ComplianceWitness
8-
alias AnomaSDK.Arm.MerklePath
9-
alias AnomaSDK.Arm.NullifierKey
10-
alias AnomaSDK.Arm.Resource
7+
alias Anoma.Arm.ComplianceWitness
8+
alias Anoma.Arm.MerklePath
9+
alias Anoma.Arm.NullifierKey
10+
alias Anoma.Arm.Resource
1111

12-
import AnomaSDK.Arm.Constants
12+
import Anoma.Arm.Constants
1313

1414
typedstruct do
1515
field(:consumed_resource, Resource.t())
@@ -20,12 +20,12 @@ defmodule AnomaSDK.Arm.ComplianceWitness do
2020
field(:rcv, binary())
2121
end
2222

23-
defimpl Jason.Encoder, for: AnomaSDK.Arm.ComplianceWitness do
23+
defimpl Jason.Encoder, for: Anoma.Arm.ComplianceWitness do
2424
@spec encode(struct(), term()) :: term()
2525
@spec encode(struct(), term()) :: term()
2626
def encode(struct, opts) do
2727
struct
28-
|> AnomaSDK.Json.encode_keys([:ephemeral_root, :nf_key, :rcv])
28+
|> Anoma.Json.encode_keys([:ephemeral_root, :nf_key, :rcv])
2929
|> Map.update!(:merkle_path, &MerklePath.to_map/1)
3030
|> Jason.Encode.map(opts)
3131
end
@@ -36,7 +36,7 @@ defmodule AnomaSDK.Arm.ComplianceWitness do
3636
consumed_resource = Resource.from_map(map.consumed_resource)
3737
merkle_path = MerklePath.from_map(map.merkle_path)
3838
created_resource = Resource.from_map(map.created_resource)
39-
map = AnomaSDK.Json.decode_keys(map, [:ephemeral_root, :nf_key, :rcv])
39+
map = Anoma.Json.decode_keys(map, [:ephemeral_root, :nf_key, :rcv])
4040

4141
struct(ComplianceWitness, %{
4242
map

0 commit comments

Comments
 (0)