11defmodule Attestation do
22 _ = """
33 attestation {
4+ hash: <>,
45 entry_hash: <>,
6+ entry_height: <>,
57 mutations_hash: <>,
8+ root_receipts: <>,
9+ root_contractstate: <>,
10+ root_entries: <>,
611 signer: <>,
712 signature: <entry_hash,mutations_hash>,
813 }
914 """
15+ #@fields [:hash, :signature, :attestation, :signer, :entry_hash, :entry_height, :mutations_hash, :root_receipts, :root_contractstate, :root_entries]
1016 @ fields [ :entry_hash , :mutations_hash , :signer , :signature ]
17+ @ fields_attestation [ :signer , :entry_hash , :entry_height , :root_receipts , :root_contractstate , :root_entries ]
1118
1219 def pack_for_db ( attestation_unpacked ) when is_binary ( attestation_unpacked ) do attestation_unpacked end
1320 def pack_for_db ( attestation_unpacked ) do
@@ -16,7 +23,7 @@ defmodule Attestation do
1623 |> RDB . vecpak_encode ( )
1724 end
1825
19- def sign ( sk , entry_hash , mutations_hash ) do
26+ def sign ( sk , entry_hash , entry_height , mutations_hash , root_receipts , root_contractstate , root_entries ) do
2027 pk = BlsEx . get_public_key! ( sk )
2128 signature = BlsEx . sign! ( sk , << entry_hash :: binary , mutations_hash :: binary >> , BLS12AggSig . dst_att ( ) )
2229 % {
@@ -38,8 +45,11 @@ defmodule Attestation do
3845 if ! is_binary ( a . signer ) , do: throw ( % { error: :signer_not_binary } )
3946 if byte_size ( a . signer ) != 48 , do: throw ( % { error: :signer_not_48_bytes } )
4047
41- claim = << a . entry_hash :: binary , a . mutations_hash :: binary >>
42- if ! BlsEx . verify? ( a . signer , a . signature , claim , BLS12AggSig . dst_att ( ) ) , do: throw ( % { error: :invalid_signature } )
48+ #if DB.Chain.height() >= RDBProtocol.forkheight() do
49+ #else
50+ claim = << a . entry_hash :: binary , a . mutations_hash :: binary >>
51+ if ! BlsEx . verify? ( a . signer , a . signature , claim , BLS12AggSig . dst_att ( ) ) , do: throw ( % { error: :invalid_signature } )
52+ #end
4353
4454 % { error: :ok , attestation: a }
4555 catch
0 commit comments