Add proof processing

This commit is contained in:
nolash
2021-10-11 19:02:42 +02:00
parent 8451285d0d
commit 09fa8f2a4c
6 changed files with 43 additions and 12 deletions

View File

@@ -55,6 +55,7 @@ class Attachment(Data):
logg.debug('writing {}'.format(k))
writer.write(k, v)
def __str__(self):
s = ''
for i in range(len(self.contents)):

View File

@@ -210,7 +210,9 @@ class CICEth:
c = Declarator(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle, gas_oracle=gas_oracle)
results = []
for proof in self.proof.get():
(main_proof, all_proofs) = self.proof.get()
for proof in all_proofs:
logg.debug('proof {} '.format(proof))
k = 'address_declarator_' + proof
o = c.add_declaration(contract_address, signer_address, self.token_address, proof, tx_format=self.tx_format)
r = None

View File

@@ -81,6 +81,7 @@ class Proof(Data):
hsh = self.hash(b).hex()
self.attachments[hsh] = self.temp_proof_path
logg.debug('cbor of {} is {} hashes to {}'.format(v, b.hex(), hsh))
if self.extra_attachments != None:
a = self.extra_attachments.asdict()
@@ -88,8 +89,27 @@ class Proof(Data):
self.attachments[k] = a[k]
hshs = self.__get_ordered_hashes()
return (hsh, hshs)
def process(self, token_address=None, writer=None):
if writer == None:
writer = self.writer
(hsh, hshs) = self.get()
hshs = list(map(strip_0x, hshs))
hshs_bin = list(map(bytes.fromhex, hshs))
hshs_cat = b''.join(hshs_bin)
r = self.hash(hshs_cat)
r_hex = r.hex()
logg.debug('generated proof {} for hashes {}'.format(r_hex, hshs))
writer.write(r_hex, hshs_cat)
return hshs
return r_hex
def __str__(self):