mirror of
https://github.com/fluencelabs/trust-graph-test
synced 2025-04-25 08:12:17 +00:00
add demo example with sign, issue and verify trust
This commit is contained in:
parent
07ce474ab5
commit
83055549df
@ -1,3 +1,3 @@
|
|||||||
import TrustGraph from "../../aqua/trust-graph.aqua"
|
import get_trust_metadata, issue_trust, verify_trust from "../../aqua/trust-graph-api.aqua"
|
||||||
|
|
||||||
export TrustGraph
|
export get_trust_metadata, issue_trust, verify_trust
|
||||||
|
@ -13,3 +13,52 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { get_trust_metadata, issue_trust, verify_trust } from "./generated/export";
|
||||||
|
import { Fluence, KeyPair } from "@fluencelabs/fluence";
|
||||||
|
import { Node } from "@fluencelabs/fluence-network-environment";
|
||||||
|
const bs58 = require('bs58');
|
||||||
|
|
||||||
|
let local: Node[] = [
|
||||||
|
{
|
||||||
|
peerId: "12D3KooWHBG9oaVx4i3vi6c1rSBUm7MLBmyGmmbHoZ23pmjDCnvK",
|
||||||
|
multiaddr:
|
||||||
|
"/ip4/127.0.0.1/tcp/9990/ws/p2p/12D3KooWHBG9oaVx4i3vi6c1rSBUm7MLBmyGmmbHoZ23pmjDCnvK",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
peerId: "12D3KooWRABanQHUn28dxavN9ZS1zZghqoZVAYtFpoN7FdtoGTFv",
|
||||||
|
multiaddr:
|
||||||
|
"/ip4/127.0.0.1/tcp/9991/ws/p2p/12D3KooWRABanQHUn28dxavN9ZS1zZghqoZVAYtFpoN7FdtoGTFv",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
async function main(environment: Node[]) {
|
||||||
|
await Fluence.start({ connectTo: environment[0] });
|
||||||
|
console.log(
|
||||||
|
"📗 created a fluence peer %s with relay %s",
|
||||||
|
Fluence.getStatus().peerId,
|
||||||
|
Fluence.getStatus().relayPeerId
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
let trust_metadata = await get_trust_metadata(local[0].peerId, local[1].peerId, 99999999999, 0);
|
||||||
|
const issuer_kp = await KeyPair.fromBytes(bs58.decode("29Apzfedhw2Jxh94Jj4rNSmavQ1TkNe8ALYRA7bMegobwp423aLrURxLk32WtXgXHDqoSz7GAT9fQfoMhVd1e5Ww"));
|
||||||
|
console.log("Issuer peer id: %", issuer_kp.Libp2pPeerId.toB58String());
|
||||||
|
const signed_metadata = await issuer_kp.Libp2pPeerId.privKey.sign(Uint8Array.from(trust_metadata.result));
|
||||||
|
let trust = await issue_trust(local[0].peerId, local[1].peerId, 99999999999, 0, Array.from(signed_metadata));
|
||||||
|
console.log("Trust %s", trust.trust);
|
||||||
|
let result = await verify_trust(local[0].peerId, trust.trust, local[0].peerId);
|
||||||
|
console.log("Verify trust result: %s", result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let environment: Node[];
|
||||||
|
environment = local;
|
||||||
|
console.log("📘 Will connect to local nodes");
|
||||||
|
|
||||||
|
main(environment)
|
||||||
|
.then(() => process.exit(0))
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
# management secret key is NAB5rGwT4qOEB+6nLQawkTfCOV2eiFSjgQK8bfEdZXY=
|
# management secret key is NAB5rGwT4qOEB+6nLQawkTfCOV2eiFSjgQK8bfEdZXY=
|
||||||
services:
|
services:
|
||||||
fluence-0: # /ip4/127.0.0.1/tcp/9990/ws/p2p/12D3KooWHBG9oaVx4i3vi6c1rSBUm7MLBmyGmmbHoZ23pmjDCnvK
|
fluence-0: # /ip4/127.0.0.1/tcp/9990/ws/p2p/12D3KooWHBG9oaVx4i3vi6c1rSBUm7MLBmyGmmbHoZ23pmjDCnvK
|
||||||
command: -f ed25519 -k 29Apzfedhw2Jxh94Jj4rNSmavQ1TkNe8ALYRA7bMegobwp423aLrURxLk32WtXgXHDqoSz7GAT9fQfoMhVd1e5Ww -m 12D3KooWFRgVmb1uWcmCbmJqLr8tBQghL6ysSpK2VyE2VZbaQ6wy -t 7770 -w 9990 --bootstraps /dns4/fluence-1/tcp/7771 /dns4/fluence-2/tcp/7772
|
command: -f ed25519 -k 29Apzfedhw2Jxh94Jj4rNSmavQ1TkNe8ALYRA7bMegobwp423aLrURxLk32WtXgXHDqoSz7GAT9fQfoMhVd1e5Ww -m 12D3KooWFRgVmb1uWcmCbmJqLr8tBQghL6ysSpK2VyE2VZbaQ6wy -t 7770 -w 9990 # --bootstraps /dns4/fluence-1/tcp/7771 /dns4/fluence-2/tcp/7772
|
||||||
container_name: fluence-0
|
container_name: fluence-0
|
||||||
environment:
|
environment:
|
||||||
RUST_BACKTRACE: full
|
RUST_BACKTRACE: full
|
||||||
RUST_LOG: info,network=trace,aquamarine=info,aquamarine::actor=info,tokio_threadpool=info,tokio_reactor=info,mio=info,tokio_io=info,soketto=info,yamux=info,multistream_select=info,libp2p_secio=info,libp2p_websocket::framed=info,libp2p_ping=info,libp2p_core::upgrade::apply=info,libp2p_kad::kbucket=info,cranelift_codegen=info,wasmer_wasi=info,async_io=info,polling=info,wasmer_interface_types_fl=info,cranelift_codegen=info,wasmer_wasi=info,async_io=info,polling=info,wasmer_interface_types_fl=info,particle_server::behaviour::identify=info,libp2p_mplex=info,libp2p_identify=info,walrus=info,particle_protocol::libp2p_protocol::upgrade=info,kademlia::behaviour=info
|
RUST_LOG: info,network=trace,aquamarine=info,aquamarine::actor=info,tokio_threadpool=info,tokio_reactor=info,mio=info,tokio_io=info,soketto=info,yamux=info,multistream_select=info,libp2p_secio=info,libp2p_websocket::framed=info,libp2p_ping=info,libp2p_core::upgrade::apply=info,libp2p_kad::kbucket=info,cranelift_codegen=info,wasmer_wasi=info,async_io=info,polling=info,wasmer_interface_types_fl=info,cranelift_codegen=info,wasmer_wasi=info,async_io=info,polling=info,wasmer_interface_types_fl=info,particle_server::behaviour::identify=info,libp2p_mplex=info,libp2p_identify=info,walrus=info,particle_protocol::libp2p_protocol::upgrade=info,kademlia::behaviour=info
|
||||||
WASM_LOG: info
|
WASM_LOG: info
|
||||||
image: fluencelabs/node:latest
|
image: fluencelabs/node:tg_test
|
||||||
ports:
|
ports:
|
||||||
- 7770:7770 # tcp
|
- 7770:7770 # tcp
|
||||||
- 9990:9990 # ws
|
- 9990:9990 # ws
|
||||||
|
Loading…
x
Reference in New Issue
Block a user