mirror of
https://github.com/fluencelabs/trust-graph
synced 2025-07-04 09:01:41 +00:00
Compare commits
31 Commits
trust-grap
...
trust-grap
Author | SHA1 | Date | |
---|---|---|---|
c22eab38c1 | |||
3692d6898d | |||
3a5f23741f | |||
b10991501d | |||
d80a43bcff | |||
a7ea41ed4d | |||
d04120bacf | |||
3ba3855892 | |||
f7ef0f8da0 | |||
2001f900fa | |||
412b8ba725 | |||
a7abe87c09 | |||
1a26a6809e | |||
93161afe0c | |||
11fd2de7b6 | |||
a8fdb4472e | |||
56d0ea27bd | |||
d0c6c62ca4 | |||
b6df3fe548 | |||
a747b9cc75 | |||
d567848cba | |||
9b942eacca | |||
c85fb16de3 | |||
97ce5bbac7 | |||
864b7f5c13 | |||
da38a41ba7 | |||
7493eed216 | |||
e9399b7d0c | |||
81eb924476 | |||
fe902acc50 | |||
f5994b33d1 |
8
.github/release-please/config.json
vendored
8
.github/release-please/config.json
vendored
@ -14,12 +14,13 @@
|
|||||||
"components": [
|
"components": [
|
||||||
"trust-graph",
|
"trust-graph",
|
||||||
"trust-graph-api",
|
"trust-graph-api",
|
||||||
"trust-graph-wasm"
|
"trust-graph-wasm",
|
||||||
|
"distro"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages": {
|
"packages": {
|
||||||
".": {
|
"trust-graph": {
|
||||||
"component": "trust-graph"
|
"component": "trust-graph"
|
||||||
},
|
},
|
||||||
"aqua": {
|
"aqua": {
|
||||||
@ -31,6 +32,9 @@
|
|||||||
},
|
},
|
||||||
"keypair": {
|
"keypair": {
|
||||||
"component": "keypair"
|
"component": "keypair"
|
||||||
|
},
|
||||||
|
"distro": {
|
||||||
|
"component": "distro"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
9
.github/release-please/manifest.json
vendored
9
.github/release-please/manifest.json
vendored
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
".": "0.4.0",
|
"trust-graph": "0.4.6",
|
||||||
"aqua": "0.4.0",
|
"aqua": "0.4.6",
|
||||||
"service": "0.4.0",
|
"service": "0.4.6",
|
||||||
"keypair": "0.10.0"
|
"keypair": "0.10.2",
|
||||||
|
"distro": "0.4.6"
|
||||||
}
|
}
|
||||||
|
19
.github/workflows/release.yml
vendored
19
.github/workflows/release.yml
vendored
@ -14,9 +14,10 @@ jobs:
|
|||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
releases-created: ${{ steps.release.outputs['releases_created'] }}
|
releases-created: ${{ steps.release.outputs['releases_created'] }}
|
||||||
trust-graph-api-release-created: ${{ steps.release.outputs['aqua--release-created'] }}
|
trust-graph-api-release-created: ${{ steps.release.outputs['aqua--release_created'] }}
|
||||||
trust-graph-release-created: ${{ steps.release.outputs['release-created'] }}
|
trust-graph-release-created: ${{ steps.release.outputs['trust-graph--release_created'] }}
|
||||||
trust-graph-tag-name: ${{ steps.release.outputs['tag_name'] }}
|
trust-graph-tag-name: ${{ steps.release.outputs['trust-graph--tag_name'] }}
|
||||||
|
trust-graph-version: ${{ steps.release.outputs['trust-graph--version'] }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Run release-please
|
- name: Run release-please
|
||||||
@ -65,14 +66,11 @@ jobs:
|
|||||||
- name: Setup Rust toolchain
|
- name: Setup Rust toolchain
|
||||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
|
||||||
- name: Install Marine
|
- name: Setup marine
|
||||||
uses: baptiste0928/cargo-install@v1.3.0
|
uses: fluencelabs/setup-marine@v1
|
||||||
with:
|
|
||||||
crate: marine
|
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: ./build.sh
|
run: ./build.sh
|
||||||
working-directory: service
|
|
||||||
|
|
||||||
- name: Install cargo-workspaces
|
- name: Install cargo-workspaces
|
||||||
uses: baptiste0928/cargo-install@v1.3.0
|
uses: baptiste0928/cargo-install@v1.3.0
|
||||||
@ -107,6 +105,9 @@ jobs:
|
|||||||
run: npm publish --access public
|
run: npm publish --access public
|
||||||
working-directory: aqua
|
working-directory: aqua
|
||||||
|
|
||||||
|
- name: Install ipfs
|
||||||
|
uses: nahsi/setup-ipfs@v1
|
||||||
|
|
||||||
- name: Create builtin distribution package
|
- name: Create builtin distribution package
|
||||||
if: needs.release-please.outputs.trust-graph-release-created
|
if: needs.release-please.outputs.trust-graph-release-created
|
||||||
run: ./builtin-package/package.sh
|
run: ./builtin-package/package.sh
|
||||||
@ -138,7 +139,7 @@ jobs:
|
|||||||
token: ${{ secrets.PERSONAL_TOKEN }}
|
token: ${{ secrets.PERSONAL_TOKEN }}
|
||||||
inputs: '{
|
inputs: '{
|
||||||
"name": "trust-graph",
|
"name": "trust-graph",
|
||||||
"version": "${{ needs.release-please.outputs.version }}",
|
"version": "${{ needs.release-please.outputs.trust-graph-version }}",
|
||||||
"url": "https://github.com/fluencelabs/trust-graph/releases/download/${{ needs.release-please.outputs.trust-graph-tag-name }}/trust-graph.tar.gz",
|
"url": "https://github.com/fluencelabs/trust-graph/releases/download/${{ needs.release-please.outputs.trust-graph-tag-name }}/trust-graph.tar.gz",
|
||||||
"sha256": "${{ steps.sha.outputs.sha256 }}"
|
"sha256": "${{ steps.sha.outputs.sha256 }}"
|
||||||
}'
|
}'
|
||||||
|
13
.github/workflows/tests.yml
vendored
13
.github/workflows/tests.yml
vendored
@ -19,13 +19,10 @@ jobs:
|
|||||||
- name: Setup Rust toolchain
|
- name: Setup Rust toolchain
|
||||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
|
|
||||||
- name: Install marine
|
- name: Setup marine
|
||||||
uses: baptiste0928/cargo-install@v1.3.0
|
uses: fluencelabs/setup-marine@v1
|
||||||
with:
|
|
||||||
crate: marine
|
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
working-directory: ./service
|
|
||||||
run: ./build.sh
|
run: ./build.sh
|
||||||
|
|
||||||
- name: Run cargo clippy
|
- name: Run cargo clippy
|
||||||
@ -44,7 +41,8 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
NEXTEST_RETRIES: 10
|
NEXTEST_RETRIES: 10
|
||||||
NEXTEST_TEST_THREADS: 10
|
NEXTEST_TEST_THREADS: 10
|
||||||
run: cargo nextest run --release --all-features --no-fail-fast
|
# exclude distro since at this point we don't have compiled wasms which are required for compilation
|
||||||
|
run: cargo nextest run --release --all-features --no-fail-fast --workspace --exclude trust-graph-distro
|
||||||
|
|
||||||
- name: Setup node
|
- name: Setup node
|
||||||
uses: actions/setup-node@v3
|
uses: actions/setup-node@v3
|
||||||
@ -60,6 +58,9 @@ jobs:
|
|||||||
- run: npm run build
|
- run: npm run build
|
||||||
working-directory: aqua
|
working-directory: aqua
|
||||||
|
|
||||||
|
- name: Install ipfs
|
||||||
|
uses: nahsi/setup-ipfs@v1
|
||||||
|
|
||||||
- name: Create distribution package
|
- name: Create distribution package
|
||||||
run: ./builtin-package/package.sh
|
run: ./builtin-package/package.sh
|
||||||
|
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,6 +2,8 @@ service/target
|
|||||||
service/artifacts
|
service/artifacts
|
||||||
builtin-package/*.wasm
|
builtin-package/*.wasm
|
||||||
trust-graph.tar.gz
|
trust-graph.tar.gz
|
||||||
|
distro/trust-graph-service
|
||||||
|
distro/target
|
||||||
|
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
**/.idea
|
**/.idea
|
||||||
|
25
CHANGELOG.md
25
CHANGELOG.md
@ -1,25 +0,0 @@
|
|||||||
# Changelog
|
|
||||||
|
|
||||||
## [0.4.0](https://github.com/fluencelabs/trust-graph/compare/trust-graph-v0.3.2...trust-graph-v0.4.0) (2023-03-15)
|
|
||||||
|
|
||||||
|
|
||||||
### ⚠ BREAKING CHANGES
|
|
||||||
|
|
||||||
* **deps:** update libp2p to 0.39.1 and other deps ([#77](https://github.com/fluencelabs/trust-graph/issues/77))
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
* **deps:** update libp2p to 0.39.1 and other deps ([#77](https://github.com/fluencelabs/trust-graph/issues/77)) ([080503d](https://github.com/fluencelabs/trust-graph/commit/080503dcfa2ecf8d09167ff9fe7f750fadf49035))
|
|
||||||
* **keypair:** add KeyPair::from_secret_key ([#50](https://github.com/fluencelabs/trust-graph/issues/50)) ([a6ce8d9](https://github.com/fluencelabs/trust-graph/commit/a6ce8d9eee20e1ea24eb27c38ac6df6d878292ae))
|
|
||||||
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
* **deps:** Update libp2p-core to 0.38 ([#51](https://github.com/fluencelabs/trust-graph/issues/51)) ([015422e](https://github.com/fluencelabs/trust-graph/commit/015422efcce41530a6cd84a25091598bc459d2e6))
|
|
||||||
|
|
||||||
|
|
||||||
### Dependencies
|
|
||||||
|
|
||||||
* The following workspace dependencies were updated
|
|
||||||
* dependencies
|
|
||||||
* fluence-keypair bumped from 0.9.0 to 0.10.0
|
|
2353
Cargo.lock
generated
2353
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
29
Cargo.toml
29
Cargo.toml
@ -1,31 +1,10 @@
|
|||||||
[package]
|
|
||||||
name = "trust-graph"
|
|
||||||
version = "0.4.0"
|
|
||||||
authors = ["Fluence Labs"]
|
|
||||||
edition = "2021"
|
|
||||||
description = "trust graph"
|
|
||||||
license = "Apache-2.0"
|
|
||||||
repository = "https://github.com/fluencelabs/trust-graph"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
serde = { version = "1.0.118", features = ["derive"] }
|
|
||||||
|
|
||||||
fluence-keypair = { path = "./keypair", version = "0.10.0" }
|
|
||||||
bs58 = "0.4.0"
|
|
||||||
failure = "0.1.6"
|
|
||||||
log = "0.4.11"
|
|
||||||
ref-cast = "1.0.2"
|
|
||||||
derivative = "2.1.1"
|
|
||||||
thiserror = "1.0.23"
|
|
||||||
sha2 = "0.10.6"
|
|
||||||
rand = "0.8.5"
|
|
||||||
nonempty = "0.8.1"
|
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
|
"trust-graph",
|
||||||
"keypair",
|
"keypair",
|
||||||
"service"
|
"service",
|
||||||
|
"distro"
|
||||||
]
|
]
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
libp2p-identity = { version = "0.1.0", default-features = false, features = ["peerid", "rsa", "ed25519", "secp256k1", "multihash"] }
|
libp2p-identity = { version = "0.2.1", default-features = false }
|
||||||
|
@ -1,5 +1,41 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [0.4.6](https://github.com/fluencelabs/trust-graph/compare/trust-graph-api-v0.4.5...trust-graph-api-v0.4.6) (2023-06-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Reverts
|
||||||
|
|
||||||
|
* release master ([#110](https://github.com/fluencelabs/trust-graph/issues/110)) ([d80a43b](https://github.com/fluencelabs/trust-graph/commit/d80a43bcff721aff8fadf3d2d5c252804ce27a6c))
|
||||||
|
|
||||||
|
## [0.4.5](https://github.com/fluencelabs/trust-graph/compare/trust-graph-api-v0.4.4...trust-graph-api-v0.4.5) (2023-05-09)
|
||||||
|
|
||||||
|
|
||||||
|
### Miscellaneous Chores
|
||||||
|
|
||||||
|
* **trust-graph-api:** Synchronize trust-graph, wasm and api versions
|
||||||
|
|
||||||
|
## [0.4.4](https://github.com/fluencelabs/trust-graph/compare/trust-graph-api-v0.4.3...trust-graph-api-v0.4.4) (2023-05-09)
|
||||||
|
|
||||||
|
|
||||||
|
### Miscellaneous Chores
|
||||||
|
|
||||||
|
* **trust-graph-api:** Synchronize trust-graph, wasm and api versions
|
||||||
|
|
||||||
|
## [0.4.3](https://github.com/fluencelabs/trust-graph/compare/trust-graph-api-v0.4.1...trust-graph-api-v0.4.3) (2023-05-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Miscellaneous Chores
|
||||||
|
|
||||||
|
* **trust-graph-api:** Synchronize trust-graph, wasm and api versions
|
||||||
|
|
||||||
|
## [0.4.1](https://github.com/fluencelabs/trust-graph/compare/trust-graph-api-v0.4.0...trust-graph-api-v0.4.1) (2023-04-13)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **deps:** update aqua to 0.10.3 ([fe902ac](https://github.com/fluencelabs/trust-graph/commit/fe902acc50a6b4c6bf97c487f3e47ae0f5ef8a95))
|
||||||
|
* **deps:** update aqua-lib to 0.7.0 ([fe902ac](https://github.com/fluencelabs/trust-graph/commit/fe902acc50a6b4c6bf97c487f3e47ae0f5ef8a95))
|
||||||
|
|
||||||
## [0.4.0](https://github.com/fluencelabs/trust-graph/compare/trust-graph-api-v0.3.2...trust-graph-api-v0.4.0) (2023-03-15)
|
## [0.4.0](https://github.com/fluencelabs/trust-graph/compare/trust-graph-api-v0.3.2...trust-graph-api-v0.4.0) (2023-03-15)
|
||||||
|
|
||||||
|
|
||||||
|
4744
aqua/package-lock.json
generated
4744
aqua/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@fluencelabs/trust-graph",
|
"name": "@fluencelabs/trust-graph",
|
||||||
"version": "0.4.0",
|
"version": "0.4.6",
|
||||||
"description": "Aqua Trust Graph API library",
|
"description": "Aqua Trust Graph API library",
|
||||||
"files": [
|
"files": [
|
||||||
"*.aqua"
|
"*.aqua"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fluencelabs/aqua-lib": "^0.5.2"
|
"@fluencelabs/aqua-lib": "^0.7.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"generate-aqua": "../service/build.sh",
|
"generate-aqua": "../service/build.sh",
|
||||||
@ -31,6 +31,6 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/fluencelabs/trust-graph#readme",
|
"homepage": "https://github.com/fluencelabs/trust-graph#readme",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@fluencelabs/aqua": "^0.7.4-322"
|
"@fluencelabs/aqua": "^0.10.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
build.sh
Executable file
15
build.sh
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -o errexit -o nounset -o pipefail
|
||||||
|
|
||||||
|
# set current working directory to script directory to run script from everywhere
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
|
./service/build.sh
|
||||||
|
|
||||||
|
TARGET="distro/trust-graph-service/"
|
||||||
|
|
||||||
|
mkdir -p "$TARGET"
|
||||||
|
cp -v ./distro/init_certs.json service/artifacts/trust-graph.wasm service/artifacts/sqlite3.wasm distro/Config.toml "$TARGET"
|
||||||
|
|
||||||
|
cd distro
|
||||||
|
cargo build
|
@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "trust-graph",
|
|
||||||
"dependencies": [
|
|
||||||
"name:sqlite3",
|
|
||||||
"name:trust-graph"
|
|
||||||
]
|
|
||||||
}
|
|
@ -3,20 +3,39 @@ set -o pipefail -o nounset -o errexit
|
|||||||
|
|
||||||
# set current working directory to script directory to run script from everywhere
|
# set current working directory to script directory to run script from everywhere
|
||||||
cd "$(dirname "$0")"
|
cd "$(dirname "$0")"
|
||||||
SCRIPT_DIR="$(pwd)"
|
PACKAGE_DIR="$(pwd)/../package/trust-graph"
|
||||||
|
|
||||||
|
(
|
||||||
|
rm -rf $PACKAGE_DIR/*
|
||||||
|
mkdir -p $PACKAGE_DIR
|
||||||
|
)
|
||||||
|
|
||||||
(
|
(
|
||||||
echo "*** copy wasm files ***"
|
echo "*** copy wasm files ***"
|
||||||
cd ../service
|
cd ../service
|
||||||
cp artifacts/*.wasm "$SCRIPT_DIR"
|
cp artifacts/*.wasm "$PACKAGE_DIR"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
(
|
||||||
|
echo "*** copy on_start script ***"
|
||||||
|
cp on_start.json "$PACKAGE_DIR"
|
||||||
|
cp on_start.air "$PACKAGE_DIR"
|
||||||
|
)
|
||||||
|
|
||||||
|
TRUST_GRAPH_CID=$(ipfs add -q --only-hash --cid-version=1 --chunker=size-262144 $PACKAGE_DIR/trust-graph.wasm)
|
||||||
|
SQLITE_CID=$(ipfs add -q --only-hash --cid-version=1 --chunker=size-262144 $PACKAGE_DIR/sqlite3.wasm)
|
||||||
|
mv $PACKAGE_DIR/trust-graph.wasm "$PACKAGE_DIR"/"$TRUST_GRAPH_CID".wasm
|
||||||
|
mv $PACKAGE_DIR/sqlite3.wasm "$PACKAGE_DIR"/"$SQLITE_CID".wasm
|
||||||
|
cp trust-graph_config.json "$PACKAGE_DIR"/"$TRUST_GRAPH_CID"_config.json
|
||||||
|
cp sqlite3_config.json "$PACKAGE_DIR"/"$SQLITE_CID"_config.json
|
||||||
|
|
||||||
|
# write blueprint.json
|
||||||
|
echo "{}" | jq --arg trust_graph_cid "$TRUST_GRAPH_CID" --arg sqlite_cid "$SQLITE_CID" '{"name": "trust-graph", "dependencies":[{"/":$sqlite_cid},{"/":$trust_graph_cid}]}' > "$PACKAGE_DIR/blueprint.json"
|
||||||
|
|
||||||
(
|
(
|
||||||
echo "*** create builtin distribution package ***"
|
echo "*** create builtin distribution package ***"
|
||||||
cd ..
|
cd $PACKAGE_DIR/..
|
||||||
mv builtin-package trust-graph
|
tar -f ../trust-graph.tar.gz -zcv ./trust-graph
|
||||||
tar --exclude="package.sh" -f trust-graph.tar.gz -zcv ./trust-graph
|
|
||||||
mv trust-graph builtin-package
|
|
||||||
)
|
)
|
||||||
|
|
||||||
echo "*** done ***"
|
echo "*** done ***"
|
||||||
|
13
distro/CHANGELOG.md
Normal file
13
distro/CHANGELOG.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## [0.4.6](https://github.com/fluencelabs/trust-graph/compare/distro-v0.4.5...distro-v0.4.6) (2023-06-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* add distro crate [fixes NET-463] ([#93](https://github.com/fluencelabs/trust-graph/issues/93)) ([3ba3855](https://github.com/fluencelabs/trust-graph/commit/3ba3855892ae355962212a0a42099dd9f9820800))
|
||||||
|
|
||||||
|
|
||||||
|
### Reverts
|
||||||
|
|
||||||
|
* release master ([#110](https://github.com/fluencelabs/trust-graph/issues/110)) ([d80a43b](https://github.com/fluencelabs/trust-graph/commit/d80a43bcff721aff8fadf3d2d5c252804ce27a6c))
|
18
distro/Cargo.toml
Normal file
18
distro/Cargo.toml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
[package]
|
||||||
|
name = "trust-graph-distro"
|
||||||
|
version = "0.4.6"
|
||||||
|
edition = "2021"
|
||||||
|
build = "build.rs"
|
||||||
|
license = "Apache-2.0"
|
||||||
|
include = [ "/src", "build.rs", "Cargo.toml", "trust-graph-service"]
|
||||||
|
description = "Distribution package for the trust-graph service"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
[dependencies]
|
||||||
|
maplit = "1.0.2"
|
||||||
|
serde = "1.0.160"
|
||||||
|
serde_json = "1.0.96"
|
||||||
|
lazy_static = "1.4.0"
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
built = "0.5.2"
|
14
distro/Config.toml
Normal file
14
distro/Config.toml
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
modules_dir = "."
|
||||||
|
|
||||||
|
[[module]]
|
||||||
|
name = "sqlite3"
|
||||||
|
logger_enabled = true
|
||||||
|
|
||||||
|
[module.wasi]
|
||||||
|
mapped_dirs = { "tmp" = "data" }
|
||||||
|
[[module]]
|
||||||
|
name = "trust-graph"
|
||||||
|
logger_enabled = true
|
||||||
|
|
||||||
|
[module.wasi]
|
||||||
|
mapped_dirs = { "tmp" = "data" }
|
3
distro/build.rs
Normal file
3
distro/build.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fn main() {
|
||||||
|
built::write_built_file().expect("Failed to acquire build-time information")
|
||||||
|
}
|
1
distro/init_certs.json
Normal file
1
distro/init_certs.json
Normal file
File diff suppressed because one or more lines are too long
60
distro/src/lib.rs
Normal file
60
distro/src/lib.rs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
use lazy_static::lazy_static;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[cfg(not(feature = "cargo-clippy"))]
|
||||||
|
pub const TRUST_GRAPH_WASM: &[u8] = include_bytes!("../trust-graph-service/trust-graph.wasm");
|
||||||
|
#[cfg(feature = "cargo-clippy")]
|
||||||
|
pub const TRUST_GRAPH_WASM: &[u8] = &[];
|
||||||
|
|
||||||
|
#[cfg(not(feature = "cargo-clippy"))]
|
||||||
|
pub const SQLITE_WASM: &[u8] = include_bytes!("../trust-graph-service/sqlite3.wasm");
|
||||||
|
#[cfg(feature = "cargo-clippy")]
|
||||||
|
pub const SQLITE_WASM: &[u8] = &[];
|
||||||
|
|
||||||
|
#[cfg(not(feature = "cargo-clippy"))]
|
||||||
|
pub const CONFIG: &[u8] = include_bytes!("../trust-graph-service/Config.toml");
|
||||||
|
#[cfg(feature = "cargo-clippy")]
|
||||||
|
pub const CONFIG: &[u8] = &[];
|
||||||
|
|
||||||
|
#[cfg(not(feature = "cargo-clippy"))]
|
||||||
|
pub const KRAS_CERTS_JSON: &str = include_str!("../trust-graph-service/init_certs.json");
|
||||||
|
#[cfg(feature = "cargo-clippy")]
|
||||||
|
pub const KRAS_CERTS_JSON: &str = "{}";
|
||||||
|
|
||||||
|
pub mod build_info {
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/built.rs"));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub use build_info::PKG_VERSION as VERSION;
|
||||||
|
|
||||||
|
pub fn modules() -> std::collections::HashMap<&'static str, &'static [u8]> {
|
||||||
|
maplit::hashmap! {
|
||||||
|
"sqlite3" => SQLITE_WASM,
|
||||||
|
"trust-graph" => TRUST_GRAPH_WASM,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize)]
|
||||||
|
pub struct Certs {
|
||||||
|
pub root_node: String,
|
||||||
|
pub max_chain_length: u32,
|
||||||
|
pub certs: Vec<Cert>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize)]
|
||||||
|
pub struct Cert {
|
||||||
|
pub chain: Vec<Trust>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize)]
|
||||||
|
pub struct Trust {
|
||||||
|
pub issued_for: String,
|
||||||
|
pub expires_at: u64,
|
||||||
|
pub signature: String,
|
||||||
|
pub sig_type: String,
|
||||||
|
pub issued_at: u64,
|
||||||
|
}
|
||||||
|
|
||||||
|
lazy_static! {
|
||||||
|
pub static ref KRAS_CERTS: Certs = serde_json::from_str(KRAS_CERTS_JSON).unwrap();
|
||||||
|
}
|
@ -4,6 +4,30 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [0.10.2](https://github.com/fluencelabs/trust-graph/compare/keypair-v0.10.1...keypair-v0.10.2) (2023-06-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* update libp2p identity ([#109](https://github.com/fluencelabs/trust-graph/issues/109)) ([d04120b](https://github.com/fluencelabs/trust-graph/commit/d04120bacf802a7e1127f4955b7391b0a4353128))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **keypair:** update description ([#105](https://github.com/fluencelabs/trust-graph/issues/105)) ([f7ef0f8](https://github.com/fluencelabs/trust-graph/commit/f7ef0f8da095fe1fef80faaa0b0c2d5ef854bd16))
|
||||||
|
|
||||||
|
|
||||||
|
### Reverts
|
||||||
|
|
||||||
|
* release master ([#110](https://github.com/fluencelabs/trust-graph/issues/110)) ([d80a43b](https://github.com/fluencelabs/trust-graph/commit/d80a43bcff721aff8fadf3d2d5c252804ce27a6c))
|
||||||
|
|
||||||
|
## [0.10.1](https://github.com/fluencelabs/trust-graph/compare/keypair-v0.10.0...keypair-v0.10.1) (2023-05-02)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **keypair:** Make `KeyFormat` more convenient ([#91](https://github.com/fluencelabs/trust-graph/issues/91)) ([9b942ea](https://github.com/fluencelabs/trust-graph/commit/9b942eacca49d0468b4d7512667102363a6c9aa3))
|
||||||
|
|
||||||
## [0.10.0](https://github.com/fluencelabs/trust-graph/compare/keypair-v0.9.0...keypair-v0.10.0) (2023-03-15)
|
## [0.10.0](https://github.com/fluencelabs/trust-graph/compare/keypair-v0.9.0...keypair-v0.10.0) (2023-03-15)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "fluence-keypair"
|
name = "fluence-keypair"
|
||||||
version = "0.10.0"
|
version = "0.10.2"
|
||||||
authors = ["Fluence Labs"]
|
authors = ["Fluence Labs"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "identity"
|
description = "unified keypair API based on libp2p-identity"
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
repository = "https://github.com/fluencelabs/trust-graph"
|
repository = "https://github.com/fluencelabs/trust-graph"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = { version = "1.0.118", features = ["derive"] }
|
serde = { version = "1.0.118", features = ["derive"] }
|
||||||
bs58 = "0.4.0"
|
bs58 = "0.5.0"
|
||||||
ed25519-dalek = { version = "1.0.1", features = ["serde", "std"] }
|
ed25519-dalek = { version = "1.0.1", features = ["serde", "std"] }
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
thiserror = "1.0.23"
|
thiserror = "1.0.23"
|
||||||
@ -20,7 +20,7 @@ sha2 = "0.10.6"
|
|||||||
zeroize = "1"
|
zeroize = "1"
|
||||||
serde_bytes = "0.11"
|
serde_bytes = "0.11"
|
||||||
eyre = "0.6.5"
|
eyre = "0.6.5"
|
||||||
libp2p-identity = { workspace = true, default-features = false, features = ["peerid", "rsa", "ed25519", "secp256k1", "multihash"] }
|
libp2p-identity = { workspace = true, default-features = false, features = ["peerid", "rsa", "ed25519", "secp256k1"] }
|
||||||
multihash = { version = "0.18.0", features = ["identity"] }
|
multihash = { version = "0.18.0", features = ["identity"] }
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
|
@ -26,7 +26,7 @@ use crate::public_key::PublicKey;
|
|||||||
use crate::rsa;
|
use crate::rsa;
|
||||||
use crate::secp256k1;
|
use crate::secp256k1;
|
||||||
use crate::signature::Signature;
|
use crate::signature::Signature;
|
||||||
use libp2p_identity::PeerId;
|
use libp2p_identity::{KeyType, Keypair, PeerId};
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ use std::str::FromStr;
|
|||||||
/// let keypair = Keypair::rsa_from_pkcs8(&mut bytes);
|
/// let keypair = Keypair::rsa_from_pkcs8(&mut bytes);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum KeyFormat {
|
pub enum KeyFormat {
|
||||||
Ed25519,
|
Ed25519,
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
@ -105,6 +105,7 @@ impl From<KeyFormat> for String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum KeyPair {
|
pub enum KeyPair {
|
||||||
/// An Ed25519 keypair.
|
/// An Ed25519 keypair.
|
||||||
@ -168,6 +169,18 @@ impl KeyPair {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the key format of this keypair.
|
||||||
|
pub fn key_format(&self) -> KeyFormat {
|
||||||
|
use KeyPair::*;
|
||||||
|
|
||||||
|
match self {
|
||||||
|
Ed25519(_) => KeyFormat::Ed25519,
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
Rsa(_) => KeyFormat::Rsa,
|
||||||
|
Secp256k1(_) => KeyFormat::Secp256k1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Get the public key of this keypair.
|
/// Get the public key of this keypair.
|
||||||
pub fn public(&self) -> PublicKey {
|
pub fn public(&self) -> PublicKey {
|
||||||
use KeyPair::*;
|
use KeyPair::*;
|
||||||
@ -237,42 +250,61 @@ impl KeyPair {
|
|||||||
|
|
||||||
impl From<libp2p_identity::Keypair> for KeyPair {
|
impl From<libp2p_identity::Keypair> for KeyPair {
|
||||||
fn from(key: libp2p_identity::Keypair) -> Self {
|
fn from(key: libp2p_identity::Keypair) -> Self {
|
||||||
use libp2p_identity::Keypair::*;
|
fn convert_keypair(key: Keypair) -> eyre::Result<KeyPair> {
|
||||||
|
match key.key_type() {
|
||||||
#[allow(deprecated)] //TODO: fix it later
|
KeyType::Ed25519 => {
|
||||||
match key {
|
let kp = key.try_into_ed25519()?;
|
||||||
Ed25519(kp) => KeyPair::Ed25519(ed25519::Keypair::decode(&mut kp.encode()).unwrap()),
|
let raw_kp = ed25519::Keypair::decode(&mut kp.to_bytes())?;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
Ok(KeyPair::Ed25519(raw_kp))
|
||||||
// safety: these Keypair structures are identical
|
|
||||||
Rsa(kp) => KeyPair::Rsa(unsafe {
|
|
||||||
std::mem::transmute::<libp2p_identity::rsa::Keypair, rsa::Keypair>(kp)
|
|
||||||
}),
|
|
||||||
Secp256k1(kp) => KeyPair::Secp256k1(secp256k1::Keypair::from(
|
|
||||||
secp256k1::SecretKey::from_bytes(kp.secret().to_bytes()).unwrap(),
|
|
||||||
)),
|
|
||||||
}
|
}
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
KeyType::RSA => {
|
||||||
|
let kp = key.try_into_rsa()?;
|
||||||
|
let raw_kp = unsafe {
|
||||||
|
std::mem::transmute::<libp2p_identity::rsa::Keypair, rsa::Keypair>(kp)
|
||||||
|
};
|
||||||
|
Ok(KeyPair::Rsa(raw_kp))
|
||||||
|
}
|
||||||
|
KeyType::Secp256k1 => {
|
||||||
|
let kp = key.try_into_secp256k1()?;
|
||||||
|
let raw_kp = secp256k1::SecretKey::from_bytes(kp.secret().to_bytes())?;
|
||||||
|
Ok(KeyPair::Secp256k1(secp256k1::Keypair::from(raw_kp)))
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
convert_keypair(key).expect("Could not convert keypair")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<KeyPair> for libp2p_identity::Keypair {
|
impl From<KeyPair> for libp2p_identity::Keypair {
|
||||||
fn from(key: KeyPair) -> Self {
|
fn from(key: KeyPair) -> Self {
|
||||||
use libp2p_identity::Keypair;
|
fn convert_keypair(key: KeyPair) -> eyre::Result<libp2p_identity::Keypair> {
|
||||||
use KeyPair::*;
|
|
||||||
|
|
||||||
#[allow(deprecated)] //TODO: fix it later
|
|
||||||
match key {
|
match key {
|
||||||
Ed25519(kp) => Keypair::Ed25519(
|
KeyPair::Ed25519(kp) => {
|
||||||
libp2p_identity::ed25519::Keypair::decode(kp.encode().to_vec().as_mut_slice())
|
let kp = Keypair::ed25519_from_bytes(kp.encode().to_vec().as_mut_slice())?;
|
||||||
.unwrap(),
|
Ok(kp)
|
||||||
),
|
}
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
// safety: these Keypair structures are identical
|
// safety: these Keypair structures are identical
|
||||||
Rsa(kp) => Keypair::Rsa(unsafe {
|
KeyPair::Rsa(kp) => {
|
||||||
|
let kp = unsafe {
|
||||||
std::mem::transmute::<rsa::Keypair, libp2p_identity::rsa::Keypair>(kp)
|
std::mem::transmute::<rsa::Keypair, libp2p_identity::rsa::Keypair>(kp)
|
||||||
}),
|
};
|
||||||
Secp256k1(kp) => Keypair::Secp256k1(libp2p_identity::secp256k1::Keypair::from(
|
let kp = Keypair::from(kp);
|
||||||
libp2p_identity::secp256k1::SecretKey::from_bytes(kp.secret().to_bytes()).unwrap(),
|
Ok(kp)
|
||||||
)),
|
}
|
||||||
|
KeyPair::Secp256k1(kp) => {
|
||||||
|
let sk = libp2p_identity::secp256k1::SecretKey::try_from_bytes(
|
||||||
|
kp.secret().to_bytes(),
|
||||||
|
)?;
|
||||||
|
let kp = libp2p_identity::secp256k1::Keypair::from(sk);
|
||||||
|
let kp = Keypair::from(kp);
|
||||||
|
Ok(kp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
convert_keypair(key).expect("Could not convert key pair")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -21,7 +21,7 @@ use crate::secp256k1;
|
|||||||
use crate::signature::Signature;
|
use crate::signature::Signature;
|
||||||
|
|
||||||
use crate::key_pair::KeyFormat;
|
use crate::key_pair::KeyFormat;
|
||||||
use libp2p_identity::PeerId;
|
use libp2p_identity::{KeyType, PeerId};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
|
|
||||||
@ -126,37 +126,58 @@ impl PublicKey {
|
|||||||
|
|
||||||
impl From<libp2p_identity::PublicKey> for PublicKey {
|
impl From<libp2p_identity::PublicKey> for PublicKey {
|
||||||
fn from(key: libp2p_identity::PublicKey) -> Self {
|
fn from(key: libp2p_identity::PublicKey) -> Self {
|
||||||
use libp2p_identity::PublicKey::*;
|
fn convert_key(key: libp2p_identity::PublicKey) -> eyre::Result<PublicKey> {
|
||||||
|
match key.key_type() {
|
||||||
#[allow(deprecated)] //TODO: fix it later
|
KeyType::Ed25519 => {
|
||||||
match key {
|
let pk = key.try_into_ed25519()?;
|
||||||
Ed25519(key) => {
|
let raw_pk = ed25519::PublicKey::decode(&pk.to_bytes())?;
|
||||||
PublicKey::Ed25519(ed25519::PublicKey::decode(&key.encode()[..]).unwrap())
|
Ok(PublicKey::Ed25519(raw_pk))
|
||||||
}
|
}
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
Rsa(key) => PublicKey::Rsa(rsa::PublicKey::from_pkcs1(key.encode_pkcs1()).unwrap()),
|
KeyType::RSA => {
|
||||||
Secp256k1(key) => {
|
let pk = key.try_into_rsa()?;
|
||||||
PublicKey::Secp256k1(secp256k1::PublicKey::decode(&key.encode()[..]).unwrap())
|
let raw_pk = rsa::PublicKey::from_pkcs1(pk.encode_pkcs1())?;
|
||||||
|
Ok(PublicKey::Rsa(raw_pk))
|
||||||
|
}
|
||||||
|
KeyType::Secp256k1 => {
|
||||||
|
let pk = key.try_into_secp256k1()?;
|
||||||
|
let raw_pk = secp256k1::PublicKey::decode(&pk.to_bytes())?;
|
||||||
|
Ok(PublicKey::Secp256k1(raw_pk))
|
||||||
|
}
|
||||||
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
convert_key(key).expect("Could not convert public key")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<PublicKey> for libp2p_identity::PublicKey {
|
impl From<PublicKey> for libp2p_identity::PublicKey {
|
||||||
fn from(key: PublicKey) -> Self {
|
fn from(key: PublicKey) -> Self {
|
||||||
#[allow(deprecated)] //TODO: fix it later
|
fn convert_key(key: PublicKey) -> eyre::Result<libp2p_identity::PublicKey> {
|
||||||
match key {
|
match key {
|
||||||
PublicKey::Ed25519(key) => libp2p_identity::PublicKey::Ed25519(
|
PublicKey::Ed25519(key) => {
|
||||||
libp2p_identity::ed25519::PublicKey::decode(&key.encode()[..]).unwrap(),
|
let raw_pk =
|
||||||
),
|
libp2p_identity::ed25519::PublicKey::try_from_bytes(&key.encode())?;
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
let pk = libp2p_identity::PublicKey::from(raw_pk);
|
||||||
PublicKey::Rsa(key) => libp2p_identity::PublicKey::Rsa(
|
Ok(pk)
|
||||||
libp2p_identity::rsa::PublicKey::decode_x509(&key.encode_x509()).unwrap(),
|
|
||||||
),
|
|
||||||
PublicKey::Secp256k1(key) => libp2p_identity::PublicKey::Secp256k1(
|
|
||||||
libp2p_identity::secp256k1::PublicKey::decode(&key.encode()[..]).unwrap(),
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
|
PublicKey::Rsa(key) => {
|
||||||
|
let raw_pk =
|
||||||
|
libp2p_identity::rsa::PublicKey::try_decode_x509(&key.encode_x509())?;
|
||||||
|
let pk = libp2p_identity::PublicKey::from(raw_pk);
|
||||||
|
Ok(pk)
|
||||||
|
}
|
||||||
|
PublicKey::Secp256k1(key) => {
|
||||||
|
let raw_pk =
|
||||||
|
libp2p_identity::secp256k1::PublicKey::try_from_bytes(&key.encode())?;
|
||||||
|
let pk = libp2p_identity::PublicKey::from(raw_pk);
|
||||||
|
Ok(pk)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
convert_key(key).expect("Could not convert key")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +197,7 @@ fn as_public_key(peer_id: &PeerId) -> Option<libp2p_identity::PublicKey> {
|
|||||||
|
|
||||||
match multihash::Code::try_from(mhash.code()) {
|
match multihash::Code::try_from(mhash.code()) {
|
||||||
Ok(multihash::Code::Identity) => {
|
Ok(multihash::Code::Identity) => {
|
||||||
libp2p_identity::PublicKey::from_protobuf_encoding(mhash.digest()).ok()
|
libp2p_identity::PublicKey::try_decode_protobuf(mhash.digest()).ok()
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,6 @@ pub struct Signature(pub Vec<u8>);
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use quickcheck::*;
|
use quickcheck::*;
|
||||||
use rand::seq::SliceRandom;
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
const KEY1: &'static [u8] = include_bytes!("test/rsa-2048.pk8");
|
const KEY1: &'static [u8] = include_bytes!("test/rsa-2048.pk8");
|
||||||
@ -251,8 +250,8 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Arbitrary for SomeKeypair {
|
impl Arbitrary for SomeKeypair {
|
||||||
fn arbitrary<G: Gen>(g: &mut G) -> SomeKeypair {
|
fn arbitrary(g: &mut Gen) -> SomeKeypair {
|
||||||
let mut key = [KEY1, KEY2, KEY3].choose(g).unwrap().to_vec();
|
let mut key = g.choose(&[KEY1, KEY2, KEY3]).unwrap().to_vec();
|
||||||
SomeKeypair(Keypair::from_pkcs8(&mut key).unwrap())
|
SomeKeypair(Keypair::from_pkcs8(&mut key).unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -229,6 +229,12 @@ pub struct Signature(pub Vec<u8>);
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::{key_pair, KeyFormat};
|
||||||
|
use quickcheck::QuickCheck;
|
||||||
|
|
||||||
|
fn eq_keypairs(kp1: key_pair::KeyPair, kp2: key_pair::KeyPair) -> bool {
|
||||||
|
kp1.public() == kp2.public() && kp1.secret().unwrap() == kp2.secret().unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn secp256k1_secret_from_bytes() {
|
fn secp256k1_secret_from_bytes() {
|
||||||
@ -239,4 +245,15 @@ mod tests {
|
|||||||
assert_eq!(sk1.0.serialize(), sk2.0.serialize());
|
assert_eq!(sk1.0.serialize(), sk2.0.serialize());
|
||||||
assert_eq!(sk_bytes, [0; 32]);
|
assert_eq!(sk_bytes, [0; 32]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn secp256k1_keypair_encode_decode() {
|
||||||
|
fn prop() -> bool {
|
||||||
|
let kp1 = key_pair::KeyPair::generate(KeyFormat::Secp256k1);
|
||||||
|
let kp1_enc = libp2p_identity::Keypair::from(kp1.clone());
|
||||||
|
let kp2 = key_pair::KeyPair::from(kp1_enc);
|
||||||
|
eq_keypairs(kp1, kp2)
|
||||||
|
}
|
||||||
|
QuickCheck::new().tests(10).quickcheck(prop as fn() -> _);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,82 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
* The following workspace dependencies were updated
|
||||||
|
* dependencies
|
||||||
|
* trust-graph bumped from 0.4.1 to 0.4.2
|
||||||
|
* fluence-keypair bumped from 0.10.0 to 0.10.1
|
||||||
|
|
||||||
|
## [0.4.6](https://github.com/fluencelabs/trust-graph/compare/trust-graph-wasm-v0.4.5...trust-graph-wasm-v0.4.6) (2023-06-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Reverts
|
||||||
|
|
||||||
|
* release master ([#110](https://github.com/fluencelabs/trust-graph/issues/110)) ([d80a43b](https://github.com/fluencelabs/trust-graph/commit/d80a43bcff721aff8fadf3d2d5c252804ce27a6c))
|
||||||
|
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
* The following workspace dependencies were updated
|
||||||
|
* dependencies
|
||||||
|
* trust-graph bumped from 0.4.5 to 0.4.6
|
||||||
|
* fluence-keypair bumped from 0.10.1 to 0.10.2
|
||||||
|
|
||||||
|
## [0.4.5](https://github.com/fluencelabs/trust-graph/compare/trust-graph-wasm-v0.4.4...trust-graph-wasm-v0.4.5) (2023-05-09)
|
||||||
|
|
||||||
|
|
||||||
|
### Miscellaneous Chores
|
||||||
|
|
||||||
|
* **trust-graph-wasm:** Synchronize trust-graph, wasm and api versions
|
||||||
|
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
* The following workspace dependencies were updated
|
||||||
|
* dependencies
|
||||||
|
* trust-graph bumped from 0.4.4 to 0.4.5
|
||||||
|
|
||||||
|
## [0.4.4](https://github.com/fluencelabs/trust-graph/compare/trust-graph-wasm-v0.4.3...trust-graph-wasm-v0.4.4) (2023-05-09)
|
||||||
|
|
||||||
|
|
||||||
|
### Miscellaneous Chores
|
||||||
|
|
||||||
|
* **trust-graph-wasm:** Synchronize trust-graph, wasm and api versions
|
||||||
|
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
* The following workspace dependencies were updated
|
||||||
|
* dependencies
|
||||||
|
* trust-graph bumped from 0.4.3 to 0.4.4
|
||||||
|
|
||||||
|
## [0.4.3](https://github.com/fluencelabs/trust-graph/compare/trust-graph-wasm-v0.4.2...trust-graph-wasm-v0.4.3) (2023-05-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Miscellaneous Chores
|
||||||
|
|
||||||
|
* **trust-graph-wasm:** Synchronize trust-graph, wasm and api versions
|
||||||
|
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
* The following workspace dependencies were updated
|
||||||
|
* dependencies
|
||||||
|
* trust-graph bumped from 0.4.2 to 0.4.3
|
||||||
|
|
||||||
|
## [0.4.1](https://github.com/fluencelabs/trust-graph/compare/trust-graph-wasm-v0.4.0...trust-graph-wasm-v0.4.1) (2023-04-13)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **deps:** Add trust-graph to workspace and bump sqlite-wasm version ([#87](https://github.com/fluencelabs/trust-graph/issues/87)) ([da38a41](https://github.com/fluencelabs/trust-graph/commit/da38a41ba727a14774a71bba6612b1bf1f498db9))
|
||||||
|
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
* The following workspace dependencies were updated
|
||||||
|
* dependencies
|
||||||
|
* trust-graph bumped from 0.4.0 to 0.4.1
|
||||||
|
|
||||||
## [0.4.0](https://github.com/fluencelabs/trust-graph/compare/trust-graph-wasm-v0.3.2...trust-graph-wasm-v0.4.0) (2023-03-15)
|
## [0.4.0](https://github.com/fluencelabs/trust-graph/compare/trust-graph-wasm-v0.3.2...trust-graph-wasm-v0.4.0) (2023-03-15)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "trust-graph-wasm"
|
name = "trust-graph-wasm"
|
||||||
version = "0.4.0"
|
version = "0.4.6"
|
||||||
authors = ["Fluence Labs"]
|
authors = ["Fluence Labs"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "trust graph wasm"
|
description = "trust graph wasm"
|
||||||
@ -12,8 +12,8 @@ name = "trust-graph"
|
|||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
trust-graph = { version = "0.4.0", path = "../." }
|
trust-graph = { version = "0.4.6", path = "../trust-graph" }
|
||||||
fluence-keypair = { version = "0.10.0", path = "../keypair" }
|
fluence-keypair = { version = "0.10.2", path = "../keypair" }
|
||||||
marine-rs-sdk = { version = "0.7.1", features = ["logger"] }
|
marine-rs-sdk = { version = "0.7.1", features = ["logger"] }
|
||||||
marine-sqlite-connector = "0.8.0"
|
marine-sqlite-connector = "0.8.0"
|
||||||
|
|
||||||
@ -29,8 +29,8 @@ bincode = "1.3.1"
|
|||||||
thiserror = "1.0.23"
|
thiserror = "1.0.23"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
marine-rs-sdk-test = "0.8.1"
|
marine-rs-sdk-test = "0.9.1"
|
||||||
rusqlite = "0.28.0"
|
rusqlite = "0.28.0"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
marine-rs-sdk-test = "0.8.1"
|
marine-rs-sdk-test = "0.9.1"
|
||||||
|
@ -5,12 +5,10 @@ modules_dir = "artifacts/"
|
|||||||
logger_enabled = true
|
logger_enabled = true
|
||||||
|
|
||||||
[module.wasi]
|
[module.wasi]
|
||||||
preopened_files = ["/tmp"]
|
mapped_dirs = { "/tmp" = "data" }
|
||||||
mapped_dirs = { "tmp" = "/tmp" }
|
|
||||||
[[module]]
|
[[module]]
|
||||||
name = "trust-graph"
|
name = "trust-graph"
|
||||||
logger_enabled = true
|
logger_enabled = true
|
||||||
|
|
||||||
[module.wasi]
|
[module.wasi]
|
||||||
preopened_files = ["/tmp"]
|
mapped_dirs = { "/tmp" = "data" }
|
||||||
mapped_dirs = { "tmp" = "/tmp" }
|
|
||||||
|
@ -13,7 +13,7 @@ mkdir -p artifacts
|
|||||||
cp ../target/wasm32-wasi/release/trust-graph.wasm artifacts/
|
cp ../target/wasm32-wasi/release/trust-graph.wasm artifacts/
|
||||||
|
|
||||||
# download SQLite 3 to use in tests
|
# download SQLite 3 to use in tests
|
||||||
curl -sS -L https://github.com/fluencelabs/sqlite/releases/download/v0.15.0_w/sqlite3.wasm -o artifacts/sqlite3.wasm
|
curl -sS -L https://github.com/fluencelabs/sqlite/releases/download/sqlite-wasm-v0.18.1/sqlite3.wasm -o artifacts/sqlite3.wasm
|
||||||
|
|
||||||
# generate Aqua bindings
|
# generate Aqua bindings
|
||||||
marine aqua artifacts/trust-graph.wasm -s TrustGraph -i trust-graph > ../aqua/trust-graph.aqua
|
marine aqua artifacts/trust-graph.wasm -s TrustGraph -i trust-graph > ../aqua/trust-graph.aqua
|
||||||
|
@ -18,18 +18,18 @@
|
|||||||
mod service_tests {
|
mod service_tests {
|
||||||
marine_rs_sdk_test::include_test_env!("/marine_test_env.rs");
|
marine_rs_sdk_test::include_test_env!("/marine_test_env.rs");
|
||||||
use crate::error::ServiceError;
|
use crate::error::ServiceError;
|
||||||
use crate::storage_impl::DB_PATH;
|
|
||||||
use crate::TRUSTED_TIMESTAMP;
|
use crate::TRUSTED_TIMESTAMP;
|
||||||
use fluence_keypair::KeyPair;
|
use fluence_keypair::KeyPair;
|
||||||
use libp2p_identity::PeerId;
|
use libp2p_identity::PeerId;
|
||||||
use marine_rs_sdk::{CallParameters, SecurityTetraplet};
|
use marine_rs_sdk::{CallParameters, SecurityTetraplet};
|
||||||
use marine_test_env::trust_graph::{Certificate, Revocation, ServiceInterface, Trust};
|
use marine_test_env::trust_graph::{Certificate, Revocation, ServiceInterface, Trust};
|
||||||
use rusqlite::Connection;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
static HOST_ID: &str = "some_host_id";
|
static HOST_ID: &str = "some_host_id";
|
||||||
|
|
||||||
|
static TEST_DB_PATH: &str = "data/trust-graph.sqlite";
|
||||||
|
|
||||||
struct Auth {
|
struct Auth {
|
||||||
issuer: PeerId,
|
issuer: PeerId,
|
||||||
trust: Trust,
|
trust: Trust,
|
||||||
@ -55,12 +55,7 @@ mod service_tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn clear_env() {
|
fn clear_env() {
|
||||||
let connection = Connection::open(DB_PATH).unwrap();
|
std::fs::remove_file(TEST_DB_PATH).unwrap_or_default();
|
||||||
|
|
||||||
connection
|
|
||||||
.execute("DELETE FROM trust_relations", [])
|
|
||||||
.unwrap();
|
|
||||||
connection.execute("DELETE FROM roots", []).unwrap();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_correct_timestamp_cp(arg_number: usize) -> CallParameters {
|
fn get_correct_timestamp_cp(arg_number: usize) -> CallParameters {
|
||||||
@ -445,32 +440,32 @@ mod service_tests {
|
|||||||
let mut trust_graph = marine_test_env::trust_graph::ServiceInterface::new();
|
let mut trust_graph = marine_test_env::trust_graph::ServiceInterface::new();
|
||||||
clear_env();
|
clear_env();
|
||||||
|
|
||||||
let peerA_kp = KeyPair::generate_ed25519();
|
let peer_a_kp = KeyPair::generate_ed25519();
|
||||||
let mut cur_time = 100u64;
|
let mut cur_time = 100u64;
|
||||||
add_root_with_trust(&mut trust_graph, &peerA_kp, cur_time, cur_time + 9999, 10);
|
add_root_with_trust(&mut trust_graph, &peer_a_kp, cur_time, cur_time + 9999, 10);
|
||||||
|
|
||||||
let peerB_kp = KeyPair::generate_ed25519();
|
let peer_b_kp = KeyPair::generate_ed25519();
|
||||||
add_trust(
|
add_trust(
|
||||||
&mut trust_graph,
|
&mut trust_graph,
|
||||||
&peerA_kp,
|
&peer_a_kp,
|
||||||
&peerB_kp.get_peer_id(),
|
&peer_b_kp.get_peer_id(),
|
||||||
cur_time,
|
cur_time,
|
||||||
cur_time + 99999,
|
cur_time + 99999,
|
||||||
);
|
);
|
||||||
|
|
||||||
let weight = get_weight(&mut trust_graph, peerB_kp.get_peer_id(), cur_time);
|
let weight = get_weight(&mut trust_graph, peer_b_kp.get_peer_id(), cur_time);
|
||||||
assert_ne!(weight, 0u32);
|
assert_ne!(weight, 0u32);
|
||||||
|
|
||||||
cur_time += 1;
|
cur_time += 1;
|
||||||
// A revokes B and cancels trust
|
// A revokes B and cancels trust
|
||||||
revoke(
|
revoke(
|
||||||
&mut trust_graph,
|
&mut trust_graph,
|
||||||
&peerA_kp,
|
&peer_a_kp,
|
||||||
&peerB_kp.get_peer_id(),
|
&peer_b_kp.get_peer_id(),
|
||||||
cur_time,
|
cur_time,
|
||||||
);
|
);
|
||||||
|
|
||||||
let weight = get_weight(&mut trust_graph, peerB_kp.get_peer_id(), cur_time);
|
let weight = get_weight(&mut trust_graph, peer_b_kp.get_peer_id(), cur_time);
|
||||||
assert_eq!(weight, 0u32);
|
assert_eq!(weight, 0u32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
77
trust-graph/CHANGELOG.md
Normal file
77
trust-graph/CHANGELOG.md
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
* The following workspace dependencies were updated
|
||||||
|
* dependencies
|
||||||
|
* fluence-keypair bumped from 0.10.0 to 0.10.1
|
||||||
|
|
||||||
|
## [0.4.6](https://github.com/fluencelabs/trust-graph/compare/trust-graph-v0.4.5...trust-graph-v0.4.6) (2023-06-30)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **deps:** update rust crate derivative to 2.2.0 ([2001f90](https://github.com/fluencelabs/trust-graph/commit/2001f900fa13a949decd513d8cbe15e3f006a7fc))
|
||||||
|
* **deps:** update rust crate derivative to 2.2.0 ([#88](https://github.com/fluencelabs/trust-graph/issues/88)) ([2001f90](https://github.com/fluencelabs/trust-graph/commit/2001f900fa13a949decd513d8cbe15e3f006a7fc))
|
||||||
|
|
||||||
|
|
||||||
|
### Reverts
|
||||||
|
|
||||||
|
* release master ([#110](https://github.com/fluencelabs/trust-graph/issues/110)) ([d80a43b](https://github.com/fluencelabs/trust-graph/commit/d80a43bcff721aff8fadf3d2d5c252804ce27a6c))
|
||||||
|
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
* The following workspace dependencies were updated
|
||||||
|
* dependencies
|
||||||
|
* fluence-keypair bumped from 0.10.1 to 0.10.2
|
||||||
|
|
||||||
|
## [0.4.5](https://github.com/fluencelabs/trust-graph/compare/trust-graph-v0.4.4...trust-graph-v0.4.5) (2023-05-09)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* dummy to trigger release ([#101](https://github.com/fluencelabs/trust-graph/issues/101)) ([1a26a68](https://github.com/fluencelabs/trust-graph/commit/1a26a6809ea9a90ca8ff3829a76257779a8767d5))
|
||||||
|
|
||||||
|
## [0.4.4](https://github.com/fluencelabs/trust-graph/compare/trust-graph-v0.4.3...trust-graph-v0.4.4) (2023-05-09)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* fix trust-graph package ([#98](https://github.com/fluencelabs/trust-graph/issues/98)) ([a8fdb44](https://github.com/fluencelabs/trust-graph/commit/a8fdb4472ef1676724e4bfab1b4419f07faae2d9))
|
||||||
|
|
||||||
|
## [0.4.3](https://github.com/fluencelabs/trust-graph/compare/trust-graph-v0.4.2...trust-graph-v0.4.3) (2023-05-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* dummy change for release ([#95](https://github.com/fluencelabs/trust-graph/issues/95)) ([b6df3fe](https://github.com/fluencelabs/trust-graph/commit/b6df3fe5484b0adcad0c88abe170317a837142b3))
|
||||||
|
|
||||||
|
## [0.4.1](https://github.com/fluencelabs/trust-graph/compare/trust-graph-v0.4.0...trust-graph-v0.4.1) (2023-04-13)
|
||||||
|
|
||||||
|
|
||||||
|
### Miscellaneous Chores
|
||||||
|
|
||||||
|
* **trust-graph:** Synchronize trust-graph, wasm and api versions
|
||||||
|
|
||||||
|
## [0.4.0](https://github.com/fluencelabs/trust-graph/compare/trust-graph-v0.3.2...trust-graph-v0.4.0) (2023-03-15)
|
||||||
|
|
||||||
|
|
||||||
|
### ⚠ BREAKING CHANGES
|
||||||
|
|
||||||
|
* **deps:** update libp2p to 0.39.1 and other deps ([#77](https://github.com/fluencelabs/trust-graph/issues/77))
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **deps:** update libp2p to 0.39.1 and other deps ([#77](https://github.com/fluencelabs/trust-graph/issues/77)) ([080503d](https://github.com/fluencelabs/trust-graph/commit/080503dcfa2ecf8d09167ff9fe7f750fadf49035))
|
||||||
|
* **keypair:** add KeyPair::from_secret_key ([#50](https://github.com/fluencelabs/trust-graph/issues/50)) ([a6ce8d9](https://github.com/fluencelabs/trust-graph/commit/a6ce8d9eee20e1ea24eb27c38ac6df6d878292ae))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **deps:** Update libp2p-core to 0.38 ([#51](https://github.com/fluencelabs/trust-graph/issues/51)) ([015422e](https://github.com/fluencelabs/trust-graph/commit/015422efcce41530a6cd84a25091598bc459d2e6))
|
||||||
|
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
* The following workspace dependencies were updated
|
||||||
|
* dependencies
|
||||||
|
* fluence-keypair bumped from 0.9.0 to 0.10.0
|
22
trust-graph/Cargo.toml
Normal file
22
trust-graph/Cargo.toml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
[package]
|
||||||
|
name = "trust-graph"
|
||||||
|
version = "0.4.6"
|
||||||
|
authors = ["Fluence Labs"]
|
||||||
|
edition = "2021"
|
||||||
|
description = "trust graph"
|
||||||
|
license = "Apache-2.0"
|
||||||
|
repository = "https://github.com/fluencelabs/trust-graph"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
serde = { version = "1.0.118", features = ["derive"] }
|
||||||
|
|
||||||
|
fluence-keypair = { path = "../keypair", version = "0.10.2" }
|
||||||
|
bs58 = "0.4.0"
|
||||||
|
failure = "0.1.6"
|
||||||
|
log = "0.4.11"
|
||||||
|
ref-cast = "1.0.2"
|
||||||
|
derivative = "2.2.0"
|
||||||
|
thiserror = "1.0.23"
|
||||||
|
sha2 = "0.10.6"
|
||||||
|
nonempty = "0.8.1"
|
||||||
|
rand = "0.8.5"
|
Reference in New Issue
Block a user