2022-02-04 15:45:37 +00:00
|
|
|
|
|
|
|
import "@fluencelabs/trust-graph/trust-graph-api.aqua"
|
|
|
|
import "@fluencelabs/trust-graph/trust-graph.aqua"
|
|
|
|
import "@fluencelabs/aqua-lib/builtin.aqua"
|
|
|
|
|
|
|
|
export trusted_computation
|
|
|
|
|
|
|
|
service CertOp("op"):
|
|
|
|
array_length(a: []Certificate) -> u32
|
|
|
|
|
|
|
|
service TrustedComputation("op"):
|
|
|
|
identity(s: u64) -> u64
|
|
|
|
|
2022-07-06 10:24:33 +00:00
|
|
|
func trusted_computation(node: string) -> ?u64, ?string:
|
2022-02-04 15:45:37 +00:00
|
|
|
result: ?u64
|
2022-07-06 10:24:33 +00:00
|
|
|
error: ?string
|
2022-02-04 15:45:37 +00:00
|
|
|
-- on our trusted relay
|
|
|
|
on HOST_PEER_ID:
|
|
|
|
-- get all certificates issued for given node by our client's peer id
|
|
|
|
certs_result <- get_all_certs_from(node, %init_peer_id%)
|
|
|
|
if certs_result.success:
|
|
|
|
len <- CertOp.array_length(certs_result.certificates)
|
|
|
|
-- if there is any certificate node is trusted and computation is possible
|
2022-07-06 10:24:33 +00:00
|
|
|
if len != 0:
|
|
|
|
on node:
|
|
|
|
result <- TrustedComputation.identity(5)
|
|
|
|
else:
|
|
|
|
error <<- "there is no certs for this peer"
|
|
|
|
else:
|
|
|
|
error <<- certs_result.error
|
|
|
|
<- result, error
|