trust-graph/aqua/labelling.aqua
InversionSpaces 175e51d5db
feat(trust-graph): Update aqua code (#141)
* Update aqua

* Update aqua-lib

* Update admin aqua

* Remove aqua dep

* Update example aqua

* Fix package.json

* Update admin/package.json

Co-authored-by: Aleksey Proshutinskiy <justprosh@users.noreply.github.com>

* Update aqua/package.json

Co-authored-by: Aleksey Proshutinskiy <justprosh@users.noreply.github.com>

* Update example/package.json

Co-authored-by: Aleksey Proshutinskiy <justprosh@users.noreply.github.com>

* Setup fluence in CI

---------

Co-authored-by: Aleksey Proshutinskiy <justprosh@users.noreply.github.com>
2023-12-29 13:46:10 +01:00

45 lines
1.4 KiB
Plaintext

aqua Labelling declares *
export isFluencePeer
import "misc.aqua"
import get_host_certs_from from "trust-graph-api.aqua"
alias Error: string
-- TrustGraph builtin distributed with predefined certificates which used to identify Fluence Labs peers.
-- Each certificate contains 3 trusts: self-signed fluence root trust, trust for label trust and trust to target peer.
--
-- Usage:
-- on target_node:
-- result, error <- isFluencePeer()
--
-- Returns:
-- `true, nil` if `target_node` is identified as official Fluence Labs peer
-- `false, nil` otherwise
--
-- Errors:
-- if get_host_certs_from failed, `nil, error_msg` is returned
func isFluencePeer() -> ?bool, ?Error:
fluence_root_peer_id = "12D3KooWNbZKaPWRZ8wgjGvrxdJFz9Fq5uVwkR6ERV1f74HhPdyB"
label_peer_id = "12D3KooWM45u7AQxsb4MuQJNYT3NWHHMLU7JTbBV66RTfF3KSzdR"
result: *bool
error: *Error
-- get all certs issued by `label_peer_id` to current host
certs_result <- get_host_certs_from(label_peer_id)
if certs_result.success:
for cert <- certs_result.certificates:
len <- TrustOp.array_length(cert.chain)
if len == 3:
if cert.chain!0.issued_for == fluence_root_peer_id:
if cert.chain!1.issued_for == label_peer_id:
result <<- true
if result == []:
result <<- false
else:
error <<- certs_result.error
<- result, error