mirror of
https://github.com/fluencelabs/trust-graph
synced 2025-04-25 15:52:12 +00:00
Compare commits
42 Commits
trust-grap
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
e2d93adb1e | ||
|
fd145c5fe1 | ||
|
bfdffee69c | ||
|
b263ce1fb1 | ||
|
6389c4cec5 | ||
|
16bf0a0995 | ||
|
175e51d5db | ||
|
34cbc3126c | ||
|
b8555e666d | ||
|
c59451de04 | ||
|
106bff637e | ||
|
120bedfafb | ||
|
48351d5562 | ||
|
0b66f4e053 | ||
|
ed5bd2c0ec | ||
|
2f336f73cf | ||
|
d378fe2509 | ||
|
80bf4aa4ff | ||
|
80757e6352 | ||
|
f2c3b2a13c | ||
|
4f657f9dae | ||
|
725d3f8f48 | ||
|
1fb02e4827 | ||
|
a37bda37a2 | ||
|
ee330a715a | ||
|
c22eab38c1 | ||
|
3692d6898d | ||
|
3a5f23741f | ||
|
b10991501d | ||
|
d80a43bcff | ||
|
a7ea41ed4d | ||
|
d04120bacf | ||
|
3ba3855892 | ||
|
f7ef0f8da0 | ||
|
2001f900fa | ||
|
412b8ba725 | ||
|
a7abe87c09 | ||
|
1a26a6809e | ||
|
93161afe0c | ||
|
11fd2de7b6 | ||
|
a8fdb4472e | ||
|
56d0ea27bd |
6
.github/release-please/config.json
vendored
6
.github/release-please/config.json
vendored
@ -14,7 +14,8 @@
|
|||||||
"components": [
|
"components": [
|
||||||
"trust-graph",
|
"trust-graph",
|
||||||
"trust-graph-api",
|
"trust-graph-api",
|
||||||
"trust-graph-wasm"
|
"trust-graph-wasm",
|
||||||
|
"distro"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -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 @@
|
|||||||
{
|
{
|
||||||
"trust-graph": "0.4.3",
|
"trust-graph": "0.4.11",
|
||||||
"aqua": "0.4.3",
|
"aqua": "0.4.11",
|
||||||
"service": "0.4.3",
|
"service": "0.4.11",
|
||||||
"keypair": "0.10.1"
|
"keypair": "0.10.4",
|
||||||
|
"distro": "0.4.11"
|
||||||
}
|
}
|
||||||
|
47
.github/workflows/release.yml
vendored
47
.github/workflows/release.yml
vendored
@ -17,6 +17,7 @@ jobs:
|
|||||||
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['trust-graph--release_created'] }}
|
trust-graph-release-created: ${{ steps.release.outputs['trust-graph--release_created'] }}
|
||||||
trust-graph-tag-name: ${{ steps.release.outputs['trust-graph--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
|
||||||
@ -70,7 +71,6 @@ jobs:
|
|||||||
|
|
||||||
- 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
|
||||||
@ -97,6 +97,12 @@ jobs:
|
|||||||
- run: npm i
|
- run: npm i
|
||||||
working-directory: aqua
|
working-directory: aqua
|
||||||
|
|
||||||
|
- name: Setup fcli
|
||||||
|
uses: fluencelabs/setup-fluence@v1
|
||||||
|
with:
|
||||||
|
artifact: fcli
|
||||||
|
version: unstable
|
||||||
|
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
working-directory: aqua
|
working-directory: aqua
|
||||||
|
|
||||||
@ -105,45 +111,6 @@ 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
|
|
||||||
if: needs.release-please.outputs.trust-graph-release-created
|
|
||||||
run: ./builtin-package/package.sh
|
|
||||||
|
|
||||||
- name: Calculate SHA256
|
|
||||||
if: needs.release-please.outputs.trust-graph-release-created
|
|
||||||
id: sha
|
|
||||||
run: |
|
|
||||||
# Calculate sha256
|
|
||||||
du -hs trust-graph.tar.gz
|
|
||||||
sha256sum trust-graph.tar.gz
|
|
||||||
sha=($(sha256sum trust-graph.tar.gz))
|
|
||||||
echo "sha256=${sha}" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Upload trust-graph package
|
|
||||||
if: needs.release-please.outputs.trust-graph-release-created
|
|
||||||
uses: softprops/action-gh-release@v1
|
|
||||||
with:
|
|
||||||
files: trust-graph.tar.gz
|
|
||||||
tag_name: ${{ needs.release-please.outputs.trust-graph-tag-name }}
|
|
||||||
|
|
||||||
- name: Update version in node-distro repo
|
|
||||||
if: needs.release-please.outputs.trust-graph-release-created
|
|
||||||
uses: benc-uk/workflow-dispatch@v1
|
|
||||||
with:
|
|
||||||
workflow: update_service
|
|
||||||
repo: fluencelabs/node-distro
|
|
||||||
ref: "main"
|
|
||||||
token: ${{ secrets.PERSONAL_TOKEN }}
|
|
||||||
inputs: '{
|
|
||||||
"name": "trust-graph",
|
|
||||||
"version": "${{ needs.release-please.outputs.version }}",
|
|
||||||
"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 }}"
|
|
||||||
}'
|
|
||||||
|
|
||||||
slack:
|
slack:
|
||||||
if: always()
|
if: always()
|
||||||
name: "Notify"
|
name: "Notify"
|
||||||
|
36
.github/workflows/tests.yml
vendored
36
.github/workflows/tests.yml
vendored
@ -2,6 +2,11 @@ name: Run tests with workflow_call
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
|
inputs:
|
||||||
|
fcli-version:
|
||||||
|
description: "@fluencelabs/cli version"
|
||||||
|
type: string
|
||||||
|
default: "main"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
trust-graph:
|
trust-graph:
|
||||||
@ -21,9 +26,10 @@ jobs:
|
|||||||
|
|
||||||
- name: Setup marine
|
- name: Setup marine
|
||||||
uses: fluencelabs/setup-marine@v1
|
uses: fluencelabs/setup-marine@v1
|
||||||
|
with:
|
||||||
|
artifact-name: marine
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
working-directory: ./service
|
|
||||||
run: ./build.sh
|
run: ./build.sh
|
||||||
|
|
||||||
- name: Run cargo clippy
|
- name: Run cargo clippy
|
||||||
@ -32,17 +38,15 @@ jobs:
|
|||||||
command: clippy
|
command: clippy
|
||||||
args: -Z unstable-options --all
|
args: -Z unstable-options --all
|
||||||
|
|
||||||
- name: Install cargo-nextest
|
- name: Setup nextest
|
||||||
uses: baptiste0928/cargo-install@v1.3.0
|
uses: taiki-e/install-action@nextest
|
||||||
with:
|
|
||||||
crate: cargo-nextest
|
|
||||||
version: 0.9.22
|
|
||||||
|
|
||||||
- name: Run cargo nextest
|
- name: Run cargo nextest
|
||||||
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
|
||||||
@ -52,20 +56,14 @@ jobs:
|
|||||||
cache-dependency-path: "aqua/package-lock.json"
|
cache-dependency-path: "aqua/package-lock.json"
|
||||||
cache: "npm"
|
cache: "npm"
|
||||||
|
|
||||||
|
- name: Setup fcli
|
||||||
|
uses: fluencelabs/setup-fluence@v1
|
||||||
|
with:
|
||||||
|
artifact: fcli
|
||||||
|
version: ${{ inputs.fcli-version }}
|
||||||
|
|
||||||
- run: npm i
|
- run: npm i
|
||||||
working-directory: aqua
|
working-directory: aqua
|
||||||
|
|
||||||
- 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
|
|
||||||
run: ./builtin-package/package.sh
|
|
||||||
|
|
||||||
- name: Upload trust-graph
|
|
||||||
uses: actions/upload-artifact@v3
|
|
||||||
with:
|
|
||||||
name: trust-graph
|
|
||||||
path: trust-graph.tar.gz
|
|
||||||
|
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
|
||||||
|
2100
Cargo.lock
generated
2100
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -2,8 +2,9 @@
|
|||||||
members = [
|
members = [
|
||||||
"trust-graph",
|
"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,19 +1,25 @@
|
|||||||
import "@fluencelabs/trust-graph/trust-graph.aqua"
|
aqua Admin
|
||||||
|
|
||||||
|
export timestamp_sec, get_trust_bytes, issue_trust
|
||||||
export get_trust_bytes, issue_trust
|
export get_trust_bytes, issue_trust
|
||||||
|
|
||||||
|
import "@fluencelabs/trust-graph/trust-graph.aqua"
|
||||||
import "@fluencelabs/aqua-lib/builtin.aqua"
|
import "@fluencelabs/aqua-lib/builtin.aqua"
|
||||||
|
|
||||||
func timestamp_sec(node: string) -> u64:
|
func timestamp_sec(node: string) -> u64:
|
||||||
on node:
|
on node:
|
||||||
result <- Peer.timestamp_sec()
|
result <- Peer.timestamp_sec()
|
||||||
|
|
||||||
<- result
|
<- result
|
||||||
|
|
||||||
func get_trust_bytes(node: string, issued_for_peer_id: string, expires_at_sec: u64, issued_at_sec: u64) -> GetTrustBytesResult:
|
func get_trust_bytes(node: string, issued_for_peer_id: string, expires_at_sec: u64, issued_at_sec: u64) -> GetTrustBytesResult:
|
||||||
on node:
|
on node:
|
||||||
result <- TrustGraph.get_trust_bytes(issued_for_peer_id, expires_at_sec, issued_at_sec)
|
result <- TrustGraph.get_trust_bytes(issued_for_peer_id, expires_at_sec, issued_at_sec)
|
||||||
|
|
||||||
<- result
|
<- result
|
||||||
|
|
||||||
func issue_trust(node: string, issued_for_peer_id: string, expires_at_sec: u64, issued_at_sec: u64, trust_bytes: []u8) ->IssueTrustResult:
|
func issue_trust(node: string, issued_for_peer_id: string, expires_at_sec: u64, issued_at_sec: u64, trust_bytes: []u8) ->IssueTrustResult:
|
||||||
on node:
|
on node:
|
||||||
result <- TrustGraph.issue_trust(issued_for_peer_id, expires_at_sec, issued_at_sec, trust_bytes)
|
result <- TrustGraph.issue_trust(issued_for_peer_id, expires_at_sec, issued_at_sec, trust_bytes)
|
||||||
|
|
||||||
<- result
|
<- result
|
||||||
|
1175
admin/package-lock.json
generated
1175
admin/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -4,7 +4,7 @@
|
|||||||
"description": "A simple example of how to use trust-graph in TS",
|
"description": "A simple example of how to use trust-graph in TS",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"compile-aqua": "aqua -i aqua -o generated",
|
"compile-aqua": "fluence aqua -i aqua -o generated",
|
||||||
"prebuild": "npm run compile-aqua",
|
"prebuild": "npm run compile-aqua",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"start": "node dist/index.js",
|
"start": "node dist/index.js",
|
||||||
@ -13,12 +13,11 @@
|
|||||||
"author": "Fluence Labs",
|
"author": "Fluence Labs",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fluencelabs/aqua": "^0.9.1-374",
|
"@fluencelabs/aqua-lib": "^0.9.0",
|
||||||
"@fluencelabs/aqua-lib": "^0.6.0",
|
|
||||||
"@fluencelabs/fluence": "^0.27.5",
|
"@fluencelabs/fluence": "^0.27.5",
|
||||||
"@fluencelabs/fluence-network-environment": "^1.0.13",
|
"@fluencelabs/fluence-network-environment": "^1.1.2",
|
||||||
"@fluencelabs/trust-graph": "file:../aqua",
|
"@fluencelabs/trust-graph": "file:../aqua",
|
||||||
"bs58": "^4.0.1"
|
"bs58": "^5.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^4.4.3"
|
"typescript": "^4.4.3"
|
||||||
|
@ -1,5 +1,66 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [0.4.11](https://github.com/fluencelabs/trust-graph/compare/trust-graph-api-v0.4.10...trust-graph-api-v0.4.11) (2024-01-17)
|
||||||
|
|
||||||
|
|
||||||
|
### Miscellaneous Chores
|
||||||
|
|
||||||
|
* **trust-graph-api:** Synchronize trust-graph, wasm and api versions
|
||||||
|
|
||||||
|
## [0.4.10](https://github.com/fluencelabs/trust-graph/compare/trust-graph-api-v0.4.9...trust-graph-api-v0.4.10) (2024-01-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **trust-graph:** Update aqua code ([#141](https://github.com/fluencelabs/trust-graph/issues/141)) ([175e51d](https://github.com/fluencelabs/trust-graph/commit/175e51d5db4d90dc6d884ce3113d68494da334a2))
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **trust-graph:** Revert release 0.4.10 ([#153](https://github.com/fluencelabs/trust-graph/issues/153)) ([b263ce1](https://github.com/fluencelabs/trust-graph/commit/b263ce1fb13b937b629608ede35b6f436023dcac))
|
||||||
|
|
||||||
|
## [0.4.9](https://github.com/fluencelabs/trust-graph/compare/trust-graph-api-v0.4.8...trust-graph-api-v0.4.9) (2023-12-28)
|
||||||
|
|
||||||
|
|
||||||
|
### Miscellaneous Chores
|
||||||
|
|
||||||
|
* **trust-graph-api:** Synchronize trust-graph, wasm and api versions
|
||||||
|
|
||||||
|
## [0.4.8](https://github.com/fluencelabs/trust-graph/compare/trust-graph-api-v0.4.7...trust-graph-api-v0.4.8) (2023-12-20)
|
||||||
|
|
||||||
|
|
||||||
|
### Miscellaneous Chores
|
||||||
|
|
||||||
|
* **trust-graph-api:** Synchronize trust-graph, wasm and api versions
|
||||||
|
|
||||||
|
## [0.4.7](https://github.com/fluencelabs/trust-graph/compare/trust-graph-api-v0.4.6...trust-graph-api-v0.4.7) (2023-07-04)
|
||||||
|
|
||||||
|
|
||||||
|
### Miscellaneous Chores
|
||||||
|
|
||||||
|
* **trust-graph-api:** Synchronize trust-graph, wasm and api versions
|
||||||
|
|
||||||
|
## [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)
|
## [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)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
aqua Labelling declares *
|
||||||
|
|
||||||
|
export isFluencePeer
|
||||||
|
|
||||||
import "misc.aqua"
|
import "misc.aqua"
|
||||||
import get_host_certs_from from "trust-graph-api.aqua"
|
import get_host_certs_from from "trust-graph-api.aqua"
|
||||||
|
|
||||||
@ -20,7 +24,7 @@ func isFluencePeer() -> ?bool, ?Error:
|
|||||||
fluence_root_peer_id = "12D3KooWNbZKaPWRZ8wgjGvrxdJFz9Fq5uVwkR6ERV1f74HhPdyB"
|
fluence_root_peer_id = "12D3KooWNbZKaPWRZ8wgjGvrxdJFz9Fq5uVwkR6ERV1f74HhPdyB"
|
||||||
label_peer_id = "12D3KooWM45u7AQxsb4MuQJNYT3NWHHMLU7JTbBV66RTfF3KSzdR"
|
label_peer_id = "12D3KooWM45u7AQxsb4MuQJNYT3NWHHMLU7JTbBV66RTfF3KSzdR"
|
||||||
|
|
||||||
result: ?bool
|
result: *bool
|
||||||
error: *Error
|
error: *Error
|
||||||
-- get all certs issued by `label_peer_id` to current host
|
-- get all certs issued by `label_peer_id` to current host
|
||||||
certs_result <- get_host_certs_from(label_peer_id)
|
certs_result <- get_host_certs_from(label_peer_id)
|
||||||
@ -32,8 +36,9 @@ func isFluencePeer() -> ?bool, ?Error:
|
|||||||
if cert.chain!0.issued_for == fluence_root_peer_id:
|
if cert.chain!0.issued_for == fluence_root_peer_id:
|
||||||
if cert.chain!1.issued_for == label_peer_id:
|
if cert.chain!1.issued_for == label_peer_id:
|
||||||
result <<- true
|
result <<- true
|
||||||
if result == nil:
|
if result == []:
|
||||||
result <<- false
|
result <<- false
|
||||||
else:
|
else:
|
||||||
error <<- certs_result.error
|
error <<- certs_result.error
|
||||||
|
|
||||||
<- result, error
|
<- result, error
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
aqua Misc declares *
|
||||||
|
|
||||||
import "trust-graph.aqua"
|
import "trust-graph.aqua"
|
||||||
|
|
||||||
alias Error: string
|
alias Error: string
|
||||||
|
14685
aqua/package-lock.json
generated
14685
aqua/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,16 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "@fluencelabs/trust-graph",
|
"name": "@fluencelabs/trust-graph",
|
||||||
"version": "0.4.3",
|
"version": "0.4.11",
|
||||||
"description": "Aqua Trust Graph API library",
|
"description": "Aqua Trust Graph API library",
|
||||||
"files": [
|
"files": [
|
||||||
"*.aqua"
|
"*.aqua"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fluencelabs/aqua-lib": "^0.7.0"
|
"@fluencelabs/aqua-lib": "^0.9.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"generate-aqua": "../service/build.sh",
|
"generate-aqua": "../service/build.sh",
|
||||||
"compile-aqua": "aqua -i . -o ./target/typescript",
|
"compile-aqua": "fluence aqua -i . -o ./target/typescript",
|
||||||
"build": "npm run compile-aqua"
|
"build": "npm run compile-aqua"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@ -29,8 +29,5 @@
|
|||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/fluencelabs/trust-graph/issues"
|
"url": "https://github.com/fluencelabs/trust-graph/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/fluencelabs/trust-graph#readme",
|
"homepage": "https://github.com/fluencelabs/trust-graph#readme"
|
||||||
"devDependencies": {
|
|
||||||
"@fluencelabs/aqua": "^0.10.3"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
aqua TrustGraphApi declares *
|
||||||
|
|
||||||
|
export set_root, issue_trust, import_trust
|
||||||
|
export add_trust, add_root_trust, verify_trust
|
||||||
|
export get_weight, get_weight_from, issue_revocation
|
||||||
|
export import_revocation, revoke, get_host_certs_from
|
||||||
|
export get_all_certs, get_all_certs_from, get_host_certs
|
||||||
|
export insert_cert
|
||||||
|
|
||||||
import Sig, Peer, PeerId from "@fluencelabs/aqua-lib/builtin.aqua"
|
import Sig, Peer, PeerId from "@fluencelabs/aqua-lib/builtin.aqua"
|
||||||
import "misc.aqua"
|
import "misc.aqua"
|
||||||
import "trust-graph.aqua"
|
import "trust-graph.aqua"
|
||||||
@ -24,7 +33,7 @@ func issue_trust(issuer: PeerId, issued_for: PeerId, expires_at_sec: u64) -> ?Tr
|
|||||||
issued_at_sec <- Peer.timestamp_sec()
|
issued_at_sec <- Peer.timestamp_sec()
|
||||||
bytes <- TrustGraph.get_trust_bytes(issued_for, expires_at_sec, issued_at_sec)
|
bytes <- TrustGraph.get_trust_bytes(issued_for, expires_at_sec, issued_at_sec)
|
||||||
|
|
||||||
result: ?Trust
|
result: *Trust
|
||||||
error: *Error
|
error: *Error
|
||||||
if bytes.success:
|
if bytes.success:
|
||||||
Sig issuer
|
Sig issuer
|
||||||
@ -41,6 +50,7 @@ func issue_trust(issuer: PeerId, issued_for: PeerId, expires_at_sec: u64) -> ?Tr
|
|||||||
error <<- sig_res.error!
|
error <<- sig_res.error!
|
||||||
else:
|
else:
|
||||||
error <<- bytes.error
|
error <<- bytes.error
|
||||||
|
|
||||||
<- result, error
|
<- result, error
|
||||||
|
|
||||||
-- Call context: any node with registered `trust-graph` service
|
-- Call context: any node with registered `trust-graph` service
|
||||||
@ -51,8 +61,9 @@ func import_trust(trust: Trust, issuer: PeerId) -> ?Error:
|
|||||||
error: *Error
|
error: *Error
|
||||||
timestamp_sec <- Peer.timestamp_sec()
|
timestamp_sec <- Peer.timestamp_sec()
|
||||||
add_result <- TrustGraph.add_trust(trust, issuer, timestamp_sec)
|
add_result <- TrustGraph.add_trust(trust, issuer, timestamp_sec)
|
||||||
if add_result.success != true:
|
if !add_result.success:
|
||||||
error <<- add_result.error
|
error <<- add_result.error
|
||||||
|
|
||||||
<- error
|
<- error
|
||||||
|
|
||||||
-- Call context: %init_peer_id%
|
-- Call context: %init_peer_id%
|
||||||
@ -70,6 +81,7 @@ func add_trust(node: PeerId, issuer: PeerId, issued_for: PeerId, expires_at_sec:
|
|||||||
on node:
|
on node:
|
||||||
import_error <- import_trust(trust!, issuer)
|
import_error <- import_trust(trust!, issuer)
|
||||||
append_error(error, import_error)
|
append_error(error, import_error)
|
||||||
|
|
||||||
<- error
|
<- error
|
||||||
|
|
||||||
-- Call context: %init_peer_id%
|
-- Call context: %init_peer_id%
|
||||||
@ -99,6 +111,7 @@ func add_root_trust(node: PeerId, peer_id: PeerId, max_chain_len: u32, expires_a
|
|||||||
func verify_trust(trust: Trust, issuer: PeerId) -> VerifyTrustResult:
|
func verify_trust(trust: Trust, issuer: PeerId) -> VerifyTrustResult:
|
||||||
timestamp_sec <- Peer.timestamp_sec()
|
timestamp_sec <- Peer.timestamp_sec()
|
||||||
result <- TrustGraph.verify_trust(trust, issuer, timestamp_sec)
|
result <- TrustGraph.verify_trust(trust, issuer, timestamp_sec)
|
||||||
|
|
||||||
<- result
|
<- result
|
||||||
|
|
||||||
-- Call context: any node with registered `trust-graph` service
|
-- Call context: any node with registered `trust-graph` service
|
||||||
@ -107,6 +120,7 @@ func verify_trust(trust: Trust, issuer: PeerId) -> VerifyTrustResult:
|
|||||||
func get_weight(peer_id: PeerId) -> WeightResult:
|
func get_weight(peer_id: PeerId) -> WeightResult:
|
||||||
timestamp_sec <- Peer.timestamp_sec()
|
timestamp_sec <- Peer.timestamp_sec()
|
||||||
result <- TrustGraph.get_weight(peer_id, timestamp_sec)
|
result <- TrustGraph.get_weight(peer_id, timestamp_sec)
|
||||||
|
|
||||||
<- result
|
<- result
|
||||||
|
|
||||||
-- Call context: any node with registered `trust-graph` service
|
-- Call context: any node with registered `trust-graph` service
|
||||||
@ -114,6 +128,7 @@ func get_weight(peer_id: PeerId) -> WeightResult:
|
|||||||
func get_weight_from(peer_id: PeerId, issuer: PeerId) -> WeightResult:
|
func get_weight_from(peer_id: PeerId, issuer: PeerId) -> WeightResult:
|
||||||
timestamp_sec <- Peer.timestamp_sec()
|
timestamp_sec <- Peer.timestamp_sec()
|
||||||
result <- TrustGraph.get_weight_from(peer_id, issuer, timestamp_sec)
|
result <- TrustGraph.get_weight_from(peer_id, issuer, timestamp_sec)
|
||||||
|
|
||||||
<- result
|
<- result
|
||||||
|
|
||||||
-- Call context: %init_peer_id%
|
-- Call context: %init_peer_id%
|
||||||
@ -127,7 +142,7 @@ func issue_revocation(revoked_by: PeerId, revoked: PeerId) -> ?Revocation, ?Erro
|
|||||||
issued_at_sec <- Peer.timestamp_sec()
|
issued_at_sec <- Peer.timestamp_sec()
|
||||||
bytes <- TrustGraph.get_revocation_bytes(revoked, issued_at_sec)
|
bytes <- TrustGraph.get_revocation_bytes(revoked, issued_at_sec)
|
||||||
|
|
||||||
result: ?Revocation
|
result: *Revocation
|
||||||
error: *Error
|
error: *Error
|
||||||
if bytes.success:
|
if bytes.success:
|
||||||
Sig revoked_by
|
Sig revoked_by
|
||||||
@ -145,6 +160,7 @@ func issue_revocation(revoked_by: PeerId, revoked: PeerId) -> ?Revocation, ?Erro
|
|||||||
error <<- sig_res.error!
|
error <<- sig_res.error!
|
||||||
else:
|
else:
|
||||||
error <<- bytes.error
|
error <<- bytes.error
|
||||||
|
|
||||||
<- result, error
|
<- result, error
|
||||||
|
|
||||||
-- Call context: any node with registered `trust-graph` service
|
-- Call context: any node with registered `trust-graph` service
|
||||||
@ -155,7 +171,7 @@ func import_revocation(revocation: Revocation) -> ?Error:
|
|||||||
error: *Error
|
error: *Error
|
||||||
timestamp_sec <- Peer.timestamp_sec()
|
timestamp_sec <- Peer.timestamp_sec()
|
||||||
add_result <- TrustGraph.revoke(revocation, timestamp_sec)
|
add_result <- TrustGraph.revoke(revocation, timestamp_sec)
|
||||||
if add_result.success != true:
|
if !add_result.success:
|
||||||
error <<- add_result.error
|
error <<- add_result.error
|
||||||
|
|
||||||
<- error
|
<- error
|
||||||
@ -176,6 +192,7 @@ func revoke(node: PeerId, revoked_by: PeerId, revoked: PeerId) -> ?Error:
|
|||||||
on node:
|
on node:
|
||||||
import_error <- import_revocation(revocation!)
|
import_error <- import_revocation(revocation!)
|
||||||
append_error(error, import_error)
|
append_error(error, import_error)
|
||||||
|
|
||||||
<- error
|
<- error
|
||||||
|
|
||||||
-- Call context: any node with registered `trust-graph` service
|
-- Call context: any node with registered `trust-graph` service
|
||||||
@ -183,6 +200,7 @@ func revoke(node: PeerId, revoked_by: PeerId, revoked: PeerId) -> ?Error:
|
|||||||
func get_host_certs_from(issuer: PeerId) -> AllCertsResult:
|
func get_host_certs_from(issuer: PeerId) -> AllCertsResult:
|
||||||
timestamp_sec <- Peer.timestamp_sec()
|
timestamp_sec <- Peer.timestamp_sec()
|
||||||
result <- TrustGraph.get_host_certs_from(issuer, timestamp_sec)
|
result <- TrustGraph.get_host_certs_from(issuer, timestamp_sec)
|
||||||
|
|
||||||
<- result
|
<- result
|
||||||
|
|
||||||
-- Call context: any node with registered `trust-graph` service
|
-- Call context: any node with registered `trust-graph` service
|
||||||
@ -190,6 +208,7 @@ func get_host_certs_from(issuer: PeerId) -> AllCertsResult:
|
|||||||
func get_all_certs(issued_for: PeerId) -> AllCertsResult:
|
func get_all_certs(issued_for: PeerId) -> AllCertsResult:
|
||||||
timestamp_sec <- Peer.timestamp_sec()
|
timestamp_sec <- Peer.timestamp_sec()
|
||||||
result <- TrustGraph.get_all_certs(issued_for, timestamp_sec)
|
result <- TrustGraph.get_all_certs(issued_for, timestamp_sec)
|
||||||
|
|
||||||
<- result
|
<- result
|
||||||
|
|
||||||
-- Call context: any node with registered `trust-graph` service
|
-- Call context: any node with registered `trust-graph` service
|
||||||
@ -197,6 +216,7 @@ func get_all_certs(issued_for: PeerId) -> AllCertsResult:
|
|||||||
func get_all_certs_from(issued_for: PeerId, issuer: PeerId) -> AllCertsResult:
|
func get_all_certs_from(issued_for: PeerId, issuer: PeerId) -> AllCertsResult:
|
||||||
timestamp_sec <- Peer.timestamp_sec()
|
timestamp_sec <- Peer.timestamp_sec()
|
||||||
result <- TrustGraph.get_all_certs_from(issued_for, issuer, timestamp_sec)
|
result <- TrustGraph.get_all_certs_from(issued_for, issuer, timestamp_sec)
|
||||||
|
|
||||||
<- result
|
<- result
|
||||||
|
|
||||||
-- Call context: any node with registered `trust-graph` service
|
-- Call context: any node with registered `trust-graph` service
|
||||||
@ -204,6 +224,7 @@ func get_all_certs_from(issued_for: PeerId, issuer: PeerId) -> AllCertsResult:
|
|||||||
func get_host_certs() -> AllCertsResult:
|
func get_host_certs() -> AllCertsResult:
|
||||||
timestamp_sec <- Peer.timestamp_sec()
|
timestamp_sec <- Peer.timestamp_sec()
|
||||||
result <- TrustGraph.get_host_certs(timestamp_sec)
|
result <- TrustGraph.get_host_certs(timestamp_sec)
|
||||||
|
|
||||||
<- result
|
<- result
|
||||||
|
|
||||||
-- Call context: any node with registered `trust-graph` service
|
-- Call context: any node with registered `trust-graph` service
|
||||||
@ -211,4 +232,5 @@ func get_host_certs() -> AllCertsResult:
|
|||||||
func insert_cert(certificate: Certificate) -> InsertResult:
|
func insert_cert(certificate: Certificate) -> InsertResult:
|
||||||
timestamp_sec <- Peer.timestamp_sec()
|
timestamp_sec <- Peer.timestamp_sec()
|
||||||
result <- TrustGraph.insert_cert(certificate, timestamp_sec)
|
result <- TrustGraph.insert_cert(certificate, timestamp_sec)
|
||||||
|
|
||||||
<- result
|
<- result
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
module TrustGraph declares *
|
aqua TrustGraph declares *
|
||||||
|
|
||||||
data AddTrustResult:
|
data AddTrustResult:
|
||||||
success: bool
|
success: bool
|
||||||
|
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
|
@ -3,10 +3,10 @@ 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")"
|
||||||
PACKAGE_DIR="$(pwd)/../package"
|
PACKAGE_DIR="$(pwd)/../package/trust-graph"
|
||||||
|
|
||||||
(
|
(
|
||||||
rm -f $PACKAGE_DIR/*
|
rm -rf $PACKAGE_DIR/*
|
||||||
mkdir -p $PACKAGE_DIR
|
mkdir -p $PACKAGE_DIR
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -34,8 +34,8 @@ echo "{}" | jq --arg trust_graph_cid "$TRUST_GRAPH_CID" --arg sqlite_cid "$SQLIT
|
|||||||
|
|
||||||
(
|
(
|
||||||
echo "*** create builtin distribution package ***"
|
echo "*** create builtin distribution package ***"
|
||||||
cd $PACKAGE_DIR
|
cd $PACKAGE_DIR/..
|
||||||
(tar cf - * | gzip) > ../trust-graph.tar.gz
|
tar -f ../trust-graph.tar.gz -zcv ./trust-graph
|
||||||
)
|
)
|
||||||
|
|
||||||
echo "*** done ***"
|
echo "*** done ***"
|
||||||
|
48
distro/CHANGELOG.md
Normal file
48
distro/CHANGELOG.md
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## [0.4.11](https://github.com/fluencelabs/trust-graph/compare/distro-v0.4.10...distro-v0.4.11) (2024-01-17)
|
||||||
|
|
||||||
|
|
||||||
|
### Miscellaneous Chores
|
||||||
|
|
||||||
|
* **distro:** Synchronize trust-graph, wasm and api versions
|
||||||
|
|
||||||
|
## [0.4.10](https://github.com/fluencelabs/trust-graph/compare/distro-v0.4.9...distro-v0.4.10) (2024-01-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **trust-graph:** Revert release 0.4.10 ([#153](https://github.com/fluencelabs/trust-graph/issues/153)) ([b263ce1](https://github.com/fluencelabs/trust-graph/commit/b263ce1fb13b937b629608ede35b6f436023dcac))
|
||||||
|
|
||||||
|
## [0.4.9](https://github.com/fluencelabs/trust-graph/compare/distro-v0.4.8...distro-v0.4.9) (2023-12-28)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **deps:** update sqlite wasm ([#135](https://github.com/fluencelabs/trust-graph/issues/135)) ([c59451d](https://github.com/fluencelabs/trust-graph/commit/c59451de04ba79152fa8d600a7b456ab24766dd0))
|
||||||
|
|
||||||
|
## [0.4.8](https://github.com/fluencelabs/trust-graph/compare/distro-v0.4.7...distro-v0.4.8) (2023-12-20)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* update marine sdk's, configs and sqlite connector ([#129](https://github.com/fluencelabs/trust-graph/issues/129)) ([0b66f4e](https://github.com/fluencelabs/trust-graph/commit/0b66f4e0536633879de46f69ac8391c72ece7e77))
|
||||||
|
|
||||||
|
## [0.4.7](https://github.com/fluencelabs/trust-graph/compare/distro-v0.4.6...distro-v0.4.7) (2023-07-04)
|
||||||
|
|
||||||
|
|
||||||
|
### Miscellaneous Chores
|
||||||
|
|
||||||
|
* **distro:** Synchronize trust-graph, wasm and api versions
|
||||||
|
|
||||||
|
## [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.11"
|
||||||
|
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 keysand 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.6.0"
|
15
distro/Config.toml
Normal file
15
distro/Config.toml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
modules_dir = "."
|
||||||
|
total_memory_limit = "Infinity"
|
||||||
|
|
||||||
|
[[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();
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
aqua Computation
|
||||||
|
|
||||||
import "@fluencelabs/trust-graph/trust-graph-api.aqua"
|
import "@fluencelabs/trust-graph/trust-graph-api.aqua"
|
||||||
import "@fluencelabs/trust-graph/trust-graph.aqua"
|
import "@fluencelabs/trust-graph/trust-graph.aqua"
|
||||||
@ -12,20 +13,21 @@ service TrustedComputation("op"):
|
|||||||
identity(s: u64) -> u64
|
identity(s: u64) -> u64
|
||||||
|
|
||||||
func trusted_computation(node: string) -> ?u64, ?string:
|
func trusted_computation(node: string) -> ?u64, ?string:
|
||||||
result: ?u64
|
result: *u64
|
||||||
error: ?string
|
error: *string
|
||||||
-- on our trusted relay
|
-- on our trusted relay
|
||||||
on HOST_PEER_ID:
|
on HOST_PEER_ID:
|
||||||
-- get all certificates issued for given node by our client's 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%)
|
certs_result <- get_all_certs_from(node, INIT_PEER_ID)
|
||||||
if certs_result.success:
|
if certs_result.success:
|
||||||
len <- CertOp.array_length(certs_result.certificates)
|
len <- CertOp.array_length(certs_result.certificates)
|
||||||
-- if there is any certificate node is trusted and computation is possible
|
-- if there is any certificate node is trusted and computation is possible
|
||||||
if len != 0:
|
if len != 0:
|
||||||
on node:
|
on node:
|
||||||
result <- TrustedComputation.identity(5)
|
result <- TrustedComputation.identity(5)
|
||||||
else:
|
else:
|
||||||
error <<- "there is no certs for this peer"
|
error <<- "there is no certs for this peer"
|
||||||
else:
|
else:
|
||||||
error <<- certs_result.error
|
error <<- certs_result.error
|
||||||
|
|
||||||
<- result, error
|
<- result, error
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
module Export
|
aqua Export
|
||||||
|
|
||||||
import add_root_trust, add_trust, revoke from "@fluencelabs/trust-graph/trust-graph-api.aqua"
|
import add_root_trust, add_trust, revoke from "@fluencelabs/trust-graph/trust-graph-api.aqua"
|
||||||
export add_root_trust, add_trust, revoke, timestamp_sec
|
|
||||||
import Peer from "@fluencelabs/aqua-lib/builtin.aqua"
|
import Peer from "@fluencelabs/aqua-lib/builtin.aqua"
|
||||||
|
|
||||||
|
export add_root_trust, add_trust, revoke, timestamp_sec
|
||||||
|
|
||||||
alias PeerId: string
|
alias PeerId: string
|
||||||
|
|
||||||
func timestamp_sec() -> u64:
|
func timestamp_sec() -> u64:
|
||||||
on HOST_PEER_ID:
|
on HOST_PEER_ID:
|
||||||
result <- Peer.timestamp_sec()
|
result <- Peer.timestamp_sec()
|
||||||
|
|
||||||
<- result
|
<- result
|
||||||
|
1555
example/package-lock.json
generated
1555
example/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -4,7 +4,7 @@
|
|||||||
"description": "A simple example of how to use trust-graph in TS",
|
"description": "A simple example of how to use trust-graph in TS",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"compile-aqua": "aqua -i aqua -o generated",
|
"compile-aqua": "fluence aqua -i aqua -o generated",
|
||||||
"prebuild": "npm run compile-aqua",
|
"prebuild": "npm run compile-aqua",
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"start": "node dist/index.js",
|
"start": "node dist/index.js",
|
||||||
@ -13,14 +13,14 @@
|
|||||||
"author": "Fluence Labs",
|
"author": "Fluence Labs",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fluencelabs/aqua-lib": "^0.5.2",
|
"@fluencelabs/aqua-lib": "^0.9.0",
|
||||||
"@fluencelabs/fluence": "^0.23.0",
|
"@fluencelabs/fluence": "^0.23.0",
|
||||||
"@fluencelabs/fluence-network-environment": "^1.0.10",
|
"@fluencelabs/fluence-network-environment": "^1.1.2",
|
||||||
"@fluencelabs/trust-graph": "3.0.2",
|
"@fluencelabs/trust-graph": "3.1.2",
|
||||||
"bs58": "^4.0.1"
|
"bs58": "^5.0.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"typescript": "^4.5.2",
|
"typescript": "^4.5.2",
|
||||||
"@fluencelabs/aqua": "^0.7.4-325"
|
"@fluencelabs/aqua": "^0.10.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,38 @@ 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.4](https://github.com/fluencelabs/trust-graph/compare/keypair-v0.10.3...keypair-v0.10.4) (2023-12-20)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **fluence-keypair:** bump ed25519-dalek to 0.2.0 ([#127](https://github.com/fluencelabs/trust-graph/issues/127)) ([ed5bd2c](https://github.com/fluencelabs/trust-graph/commit/ed5bd2c0ec50bef5ac7a12deacb73da491666912))
|
||||||
|
* update marine sdk's, configs and sqlite connector ([#129](https://github.com/fluencelabs/trust-graph/issues/129)) ([0b66f4e](https://github.com/fluencelabs/trust-graph/commit/0b66f4e0536633879de46f69ac8391c72ece7e77))
|
||||||
|
|
||||||
|
## [0.10.3](https://github.com/fluencelabs/trust-graph/compare/keypair-v0.10.2...keypair-v0.10.3) (2023-07-04)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **keypair:** deserialize libp2p keypair from secret key ([#116](https://github.com/fluencelabs/trust-graph/issues/116)) ([ee330a7](https://github.com/fluencelabs/trust-graph/commit/ee330a715a902e48fc9b61d662ffcd950a26379c))
|
||||||
|
|
||||||
|
## [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)
|
## [0.10.1](https://github.com/fluencelabs/trust-graph/compare/keypair-v0.10.0...keypair-v0.10.1) (2023-05-02)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,26 +1,26 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "fluence-keypair"
|
name = "fluence-keypair"
|
||||||
version = "0.10.1"
|
version = "0.10.4"
|
||||||
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 = "2.0.0", features = ["serde", "std", "rand_core"] }
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
thiserror = "1.0.23"
|
thiserror = "1.0.23"
|
||||||
lazy_static = "1.2"
|
lazy_static = "1.4"
|
||||||
libsecp256k1 = "0.7.1"
|
libsecp256k1 = "0.7.1"
|
||||||
asn1_der = "0.6.1"
|
asn1_der = "0.6.1"
|
||||||
sha2 = "0.10.6"
|
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]
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "nightly-2022-08-30"
|
channel = "nightly-2023-12-06"
|
||||||
targets = [ "x86_64-apple-darwin", "x86_64-unknown-linux-gnu" ]
|
targets = [ "x86_64-apple-darwin", "x86_64-unknown-linux-gnu" ]
|
||||||
|
@ -19,16 +19,16 @@
|
|||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
//! Ed25519 keys.
|
//! Ed25519 keys.
|
||||||
use crate::error::{DecodingError, SigningError, VerificationError};
|
use crate::error::{DecodingError, DecodingError::InvalidLength, SigningError, VerificationError};
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use ed25519_dalek::{self as ed25519, Signer as _, Verifier as _};
|
use ed25519_dalek::{self as ed25519, Signer as _, Verifier as _};
|
||||||
use rand::RngCore;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use zeroize::Zeroize;
|
use zeroize::Zeroize;
|
||||||
|
|
||||||
/// An Ed25519 keypair.
|
/// An Ed25519 keypair
|
||||||
pub struct Keypair(ed25519::Keypair);
|
#[derive(Clone)]
|
||||||
|
pub struct Keypair(ed25519::SigningKey);
|
||||||
|
|
||||||
impl Keypair {
|
impl Keypair {
|
||||||
/// Generate a new Ed25519 keypair.
|
/// Generate a new Ed25519 keypair.
|
||||||
@ -40,13 +40,15 @@ impl Keypair {
|
|||||||
/// of the secret scalar and the compressed public point,
|
/// of the secret scalar and the compressed public point,
|
||||||
/// an informal standard for encoding Ed25519 keypairs.
|
/// an informal standard for encoding Ed25519 keypairs.
|
||||||
pub fn encode(&self) -> [u8; 64] {
|
pub fn encode(&self) -> [u8; 64] {
|
||||||
self.0.to_bytes()
|
self.0.to_keypair_bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Decode a keypair from the format produced by `encode`,
|
/// Decode a keypair from the format produced by `encode`,
|
||||||
/// zeroing the input on success.
|
/// zeroing the input on success.
|
||||||
pub fn decode(kp: &mut [u8]) -> Result<Self, DecodingError> {
|
pub fn decode(kp: &mut [u8]) -> Result<Self, DecodingError> {
|
||||||
ed25519::Keypair::from_bytes(kp)
|
let bytes = <[u8; 64]>::try_from(&*kp).map_err(InvalidLength)?;
|
||||||
|
|
||||||
|
ed25519::SigningKey::from_keypair_bytes(&bytes)
|
||||||
.map(|k| {
|
.map(|k| {
|
||||||
kp.zeroize();
|
kp.zeroize();
|
||||||
Keypair(k)
|
Keypair(k)
|
||||||
@ -61,12 +63,12 @@ impl Keypair {
|
|||||||
|
|
||||||
/// Get the public key of this keypair.
|
/// Get the public key of this keypair.
|
||||||
pub fn public(&self) -> PublicKey {
|
pub fn public(&self) -> PublicKey {
|
||||||
PublicKey(self.0.public)
|
PublicKey(self.0.verifying_key())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the secret key of this keypair.
|
/// Get the secret key of this keypair.
|
||||||
pub fn secret(&self) -> SecretKey {
|
pub fn secret(&self) -> SecretKey {
|
||||||
SecretKey::from_bytes(&mut self.0.secret.to_bytes())
|
SecretKey::from_bytes(&mut self.0.to_bytes())
|
||||||
.expect("ed25519::SecretKey::from_bytes(to_bytes(k)) != k")
|
.expect("ed25519::SecretKey::from_bytes(to_bytes(k)) != k")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,26 +76,14 @@ impl Keypair {
|
|||||||
impl fmt::Debug for Keypair {
|
impl fmt::Debug for Keypair {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
f.debug_struct("Keypair")
|
f.debug_struct("Keypair")
|
||||||
.field("public", &self.0.public)
|
.field("public", &self.0.verifying_key())
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clone for Keypair {
|
|
||||||
fn clone(&self) -> Self {
|
|
||||||
let mut sk_bytes = self.0.secret.to_bytes();
|
|
||||||
let secret = SecretKey::from_bytes(&mut sk_bytes)
|
|
||||||
.expect("ed25519::SecretKey::from_bytes(to_bytes(k)) != k")
|
|
||||||
.0;
|
|
||||||
let public = ed25519::PublicKey::from_bytes(&self.0.public.to_bytes())
|
|
||||||
.expect("ed25519::PublicKey::from_bytes(to_bytes(k)) != k");
|
|
||||||
Keypair(ed25519::Keypair { secret, public })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Build keypair from existing ed25519 keypair
|
/// Build keypair from existing ed25519 keypair
|
||||||
impl From<ed25519::Keypair> for Keypair {
|
impl From<ed25519::SigningKey> for Keypair {
|
||||||
fn from(kp: ed25519::Keypair) -> Self {
|
fn from(kp: ed25519::SigningKey) -> Self {
|
||||||
Keypair(kp)
|
Keypair(kp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,25 +91,21 @@ impl From<ed25519::Keypair> for Keypair {
|
|||||||
/// Demote an Ed25519 keypair to a secret key.
|
/// Demote an Ed25519 keypair to a secret key.
|
||||||
impl From<Keypair> for SecretKey {
|
impl From<Keypair> for SecretKey {
|
||||||
fn from(kp: Keypair) -> Self {
|
fn from(kp: Keypair) -> Self {
|
||||||
SecretKey(kp.0.secret)
|
SecretKey(kp.0.to_bytes())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Promote an Ed25519 secret key into a keypair.
|
/// Promote an Ed25519 secret key into a keypair.
|
||||||
impl From<SecretKey> for Keypair {
|
impl From<SecretKey> for Keypair {
|
||||||
fn from(sk: SecretKey) -> Self {
|
fn from(sk: SecretKey) -> Self {
|
||||||
let secret: ed25519::ExpandedSecretKey = (&sk.0).into();
|
let signing = ed25519::SigningKey::from_bytes(&sk.0);
|
||||||
let public = ed25519::PublicKey::from(&secret);
|
Keypair(signing)
|
||||||
Keypair(ed25519::Keypair {
|
|
||||||
secret: sk.0,
|
|
||||||
public,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An Ed25519 public key.
|
/// An Ed25519 public key.
|
||||||
#[derive(PartialEq, Eq, Debug, Clone, Deserialize, Serialize)]
|
#[derive(PartialEq, Eq, Debug, Clone, Deserialize, Serialize)]
|
||||||
pub struct PublicKey(ed25519::PublicKey);
|
pub struct PublicKey(ed25519::VerifyingKey);
|
||||||
|
|
||||||
impl PublicKey {
|
impl PublicKey {
|
||||||
/// Verify the Ed25519 signature on a message using the public key.
|
/// Verify the Ed25519 signature on a message using the public key.
|
||||||
@ -143,26 +129,21 @@ impl PublicKey {
|
|||||||
|
|
||||||
/// Decode a public key from a byte array as produced by `encode`.
|
/// Decode a public key from a byte array as produced by `encode`.
|
||||||
pub fn decode(bytes: &[u8]) -> Result<Self, DecodingError> {
|
pub fn decode(bytes: &[u8]) -> Result<Self, DecodingError> {
|
||||||
ed25519::PublicKey::from_bytes(bytes)
|
let bytes = <[u8; 32]>::try_from(bytes).map_err(InvalidLength)?;
|
||||||
|
ed25519::VerifyingKey::from_bytes(&bytes)
|
||||||
.map_err(DecodingError::Ed25519)
|
.map_err(DecodingError::Ed25519)
|
||||||
.map(PublicKey)
|
.map(PublicKey)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An Ed25519 secret key.
|
/// An Ed25519 secret key.
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct SecretKey(pub ed25519::SecretKey);
|
pub struct SecretKey(pub ed25519::SecretKey);
|
||||||
|
|
||||||
/// View the bytes of the secret key.
|
/// View the bytes of the secret key.
|
||||||
impl AsRef<[u8]> for SecretKey {
|
impl AsRef<[u8]> for SecretKey {
|
||||||
fn as_ref(&self) -> &[u8] {
|
fn as_ref(&self) -> &[u8] {
|
||||||
self.0.as_bytes()
|
&self.0[..]
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Clone for SecretKey {
|
|
||||||
fn clone(&self) -> Self {
|
|
||||||
let mut sk_bytes = self.0.to_bytes();
|
|
||||||
Self::from_bytes(&mut sk_bytes).expect("ed25519::SecretKey::from_bytes(to_bytes(k)) != k")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,13 +156,8 @@ impl fmt::Debug for SecretKey {
|
|||||||
impl SecretKey {
|
impl SecretKey {
|
||||||
/// Generate a new Ed25519 secret key.
|
/// Generate a new Ed25519 secret key.
|
||||||
pub fn generate() -> Self {
|
pub fn generate() -> Self {
|
||||||
let mut bytes = [0u8; 32];
|
let signing = ed25519::SigningKey::generate(&mut rand::rngs::OsRng);
|
||||||
rand::thread_rng().fill_bytes(&mut bytes);
|
SecretKey(signing.to_bytes())
|
||||||
SecretKey(
|
|
||||||
ed25519::SecretKey::from_bytes(&bytes).expect(
|
|
||||||
"this returns `Err` only if the length is wrong; the length is correct; qed",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create an Ed25519 secret key from a byte slice, zeroing the input on success.
|
/// Create an Ed25519 secret key from a byte slice, zeroing the input on success.
|
||||||
@ -189,7 +165,7 @@ impl SecretKey {
|
|||||||
/// returned.
|
/// returned.
|
||||||
pub fn from_bytes(mut sk_bytes: impl AsMut<[u8]>) -> Result<Self, DecodingError> {
|
pub fn from_bytes(mut sk_bytes: impl AsMut<[u8]>) -> Result<Self, DecodingError> {
|
||||||
let sk_bytes = sk_bytes.as_mut();
|
let sk_bytes = sk_bytes.as_mut();
|
||||||
let secret = ed25519::SecretKey::from_bytes(&*sk_bytes).map_err(DecodingError::Ed25519)?;
|
let secret = <[u8; 32]>::try_from(&*sk_bytes).map_err(InvalidLength)?;
|
||||||
sk_bytes.zeroize();
|
sk_bytes.zeroize();
|
||||||
Ok(SecretKey(secret))
|
Ok(SecretKey(secret))
|
||||||
}
|
}
|
||||||
@ -201,10 +177,11 @@ pub struct Signature(pub Vec<u8>);
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::KeyPair;
|
||||||
use quickcheck::*;
|
use quickcheck::*;
|
||||||
|
|
||||||
fn eq_keypairs(kp1: &Keypair, kp2: &Keypair) -> bool {
|
fn eq_keypairs(kp1: &Keypair, kp2: &Keypair) -> bool {
|
||||||
kp1.public() == kp2.public() && kp1.0.secret.as_bytes() == kp2.0.secret.as_bytes()
|
kp1.public() == kp2.public() && kp1.0.to_bytes() == kp2.0.to_bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -218,11 +195,22 @@ mod tests {
|
|||||||
QuickCheck::new().tests(10).quickcheck(prop as fn() -> _);
|
QuickCheck::new().tests(10).quickcheck(prop as fn() -> _);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn ed25519_keypair_convert() {
|
||||||
|
fn prop() -> bool {
|
||||||
|
let kp1 = KeyPair::generate_ed25519();
|
||||||
|
let libp2p_kp: libp2p_identity::Keypair = kp1.clone().into();
|
||||||
|
let kp2: KeyPair = libp2p_kp.into();
|
||||||
|
kp1.public() == kp2.public() && kp1.secret().unwrap() == kp2.secret().unwrap()
|
||||||
|
}
|
||||||
|
QuickCheck::new().tests(10).quickcheck(prop as fn() -> _);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ed25519_keypair_from_secret() {
|
fn ed25519_keypair_from_secret() {
|
||||||
fn prop() -> bool {
|
fn prop() -> bool {
|
||||||
let kp1 = Keypair::generate();
|
let kp1 = Keypair::generate();
|
||||||
let mut sk = kp1.0.secret.to_bytes();
|
let mut sk = kp1.0.to_bytes();
|
||||||
let kp2 = Keypair::from(SecretKey::from_bytes(&mut sk).unwrap());
|
let kp2 = Keypair::from(SecretKey::from_bytes(&mut sk).unwrap());
|
||||||
eq_keypairs(&kp1, &kp2) && sk == [0u8; 32]
|
eq_keypairs(&kp1, &kp2) && sk == [0u8; 32]
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,8 @@ pub enum Error {
|
|||||||
/// An error during decoding of key material.
|
/// An error during decoding of key material.
|
||||||
#[derive(ThisError, Debug)]
|
#[derive(ThisError, Debug)]
|
||||||
pub enum DecodingError {
|
pub enum DecodingError {
|
||||||
|
#[error("Failed to decode, invalid length: {0}")]
|
||||||
|
InvalidLength(#[from] std::array::TryFromSliceError),
|
||||||
#[error("Failed to decode with ed25519: {0}")]
|
#[error("Failed to decode with ed25519: {0}")]
|
||||||
Ed25519(
|
Ed25519(
|
||||||
#[from]
|
#[from]
|
||||||
|
@ -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,6 @@ 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)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum KeyFormat {
|
pub enum KeyFormat {
|
||||||
Ed25519,
|
Ed25519,
|
||||||
@ -106,6 +105,7 @@ impl From<KeyFormat> for String {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum KeyPair {
|
pub enum KeyPair {
|
||||||
/// An Ed25519 keypair.
|
/// An Ed25519 keypair.
|
||||||
@ -195,7 +195,7 @@ impl KeyPair {
|
|||||||
pub fn secret(&self) -> eyre::Result<Vec<u8>> {
|
pub fn secret(&self) -> eyre::Result<Vec<u8>> {
|
||||||
use KeyPair::*;
|
use KeyPair::*;
|
||||||
match self {
|
match self {
|
||||||
Ed25519(pair) => Ok(pair.secret().0.to_bytes().to_vec()),
|
Ed25519(pair) => Ok(pair.secret().0.to_vec()),
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
Rsa(_) => Err(eyre::eyre!("secret key is not available for RSA")),
|
Rsa(_) => Err(eyre::eyre!("secret key is not available for RSA")),
|
||||||
Secp256k1(pair) => Ok(pair.secret().to_bytes().to_vec()),
|
Secp256k1(pair) => Ok(pair.secret().to_bytes().to_vec()),
|
||||||
@ -250,42 +250,63 @@ 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 {
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
std::mem::transmute::<libp2p_identity::rsa::Keypair, rsa::Keypair>(kp)
|
KeyType::RSA => {
|
||||||
}),
|
let kp = key.try_into_rsa()?;
|
||||||
Secp256k1(kp) => KeyPair::Secp256k1(secp256k1::Keypair::from(
|
let raw_kp = unsafe {
|
||||||
secp256k1::SecretKey::from_bytes(kp.secret().to_bytes()).unwrap(),
|
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::*;
|
match key {
|
||||||
|
KeyPair::Ed25519(kp) => {
|
||||||
#[allow(deprecated)] //TODO: fix it later
|
// for some reason, libp2p takes SecretKey's 32 bytes here instead of Keypair's 64 bytes
|
||||||
match key {
|
let secret_bytes = kp.secret().0;
|
||||||
Ed25519(kp) => Keypair::Ed25519(
|
let kp = libp2p_identity::Keypair::ed25519_from_bytes(secret_bytes)?;
|
||||||
libp2p_identity::ed25519::Keypair::decode(kp.encode().to_vec().as_mut_slice())
|
Ok(kp)
|
||||||
.unwrap(),
|
}
|
||||||
),
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
// safety: these Keypair structures are identical
|
||||||
// safety: these Keypair structures are identical
|
KeyPair::Rsa(kp) => {
|
||||||
Rsa(kp) => Keypair::Rsa(unsafe {
|
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(),
|
}
|
||||||
),
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
PublicKey::Secp256k1(key) => libp2p_identity::PublicKey::Secp256k1(
|
PublicKey::Rsa(key) => {
|
||||||
libp2p_identity::secp256k1::PublicKey::decode(&key.encode()[..]).unwrap(),
|
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,
|
||||||
}
|
}
|
||||||
|
@ -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() -> _);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "nightly-2022-12-06"
|
channel = "nightly-2023-12-06"
|
||||||
targets = [ "x86_64-apple-darwin", "wasm32-wasi", "wasm32-unknown-unknown", "x86_64-unknown-linux-gnu" ]
|
targets = [ "x86_64-apple-darwin", "wasm32-wasi", "wasm32-unknown-unknown", "x86_64-unknown-linux-gnu" ]
|
||||||
components = [ "rustfmt", "clippy" ]
|
components = [ "rustfmt", "clippy" ]
|
||||||
|
@ -9,6 +9,121 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
* trust-graph bumped from 0.4.1 to 0.4.2
|
* trust-graph bumped from 0.4.1 to 0.4.2
|
||||||
* fluence-keypair bumped from 0.10.0 to 0.10.1
|
* fluence-keypair bumped from 0.10.0 to 0.10.1
|
||||||
|
|
||||||
|
## [0.4.11](https://github.com/fluencelabs/trust-graph/compare/trust-graph-wasm-v0.4.10...trust-graph-wasm-v0.4.11) (2024-01-17)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **trust-graph:** Regenerate aqua bindings from wasm ([#155](https://github.com/fluencelabs/trust-graph/issues/155)) ([fd145c5](https://github.com/fluencelabs/trust-graph/commit/fd145c5fe1a115e87539ec5c9496d8b4c8bbc468))
|
||||||
|
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
* The following workspace dependencies were updated
|
||||||
|
* dependencies
|
||||||
|
* trust-graph bumped from 0.4.10 to 0.4.11
|
||||||
|
|
||||||
|
## [0.4.10](https://github.com/fluencelabs/trust-graph/compare/trust-graph-wasm-v0.4.9...trust-graph-wasm-v0.4.10) (2024-01-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **trust-graph:** Revert release 0.4.10 ([#153](https://github.com/fluencelabs/trust-graph/issues/153)) ([b263ce1](https://github.com/fluencelabs/trust-graph/commit/b263ce1fb13b937b629608ede35b6f436023dcac))
|
||||||
|
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
* The following workspace dependencies were updated
|
||||||
|
* dependencies
|
||||||
|
* trust-graph bumped from 0.4.9 to 0.4.10
|
||||||
|
|
||||||
|
## [0.4.9](https://github.com/fluencelabs/trust-graph/compare/trust-graph-wasm-v0.4.8...trust-graph-wasm-v0.4.9) (2023-12-28)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **deps:** update sqlite wasm ([#135](https://github.com/fluencelabs/trust-graph/issues/135)) ([c59451d](https://github.com/fluencelabs/trust-graph/commit/c59451de04ba79152fa8d600a7b456ab24766dd0))
|
||||||
|
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
* The following workspace dependencies were updated
|
||||||
|
* dependencies
|
||||||
|
* trust-graph bumped from 0.4.8 to 0.4.9
|
||||||
|
|
||||||
|
## [0.4.8](https://github.com/fluencelabs/trust-graph/compare/trust-graph-wasm-v0.4.7...trust-graph-wasm-v0.4.8) (2023-12-20)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* update marine sdk's, configs and sqlite connector ([#129](https://github.com/fluencelabs/trust-graph/issues/129)) ([0b66f4e](https://github.com/fluencelabs/trust-graph/commit/0b66f4e0536633879de46f69ac8391c72ece7e77))
|
||||||
|
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
* The following workspace dependencies were updated
|
||||||
|
* dependencies
|
||||||
|
* trust-graph bumped from 0.4.7 to 0.4.8
|
||||||
|
* fluence-keypair bumped from 0.10.3 to 0.10.4
|
||||||
|
|
||||||
|
## [0.4.7](https://github.com/fluencelabs/trust-graph/compare/trust-graph-wasm-v0.4.6...trust-graph-wasm-v0.4.7) (2023-07-04)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **deps:** update rust crate marine-rs-sdk-test to 0.10.0 ([#106](https://github.com/fluencelabs/trust-graph/issues/106)) ([725d3f8](https://github.com/fluencelabs/trust-graph/commit/725d3f8f48b3bf1ed8605e9ba2da5c966a145f0d))
|
||||||
|
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
* The following workspace dependencies were updated
|
||||||
|
* dependencies
|
||||||
|
* trust-graph bumped from 0.4.6 to 0.4.7
|
||||||
|
* fluence-keypair bumped from 0.10.2 to 0.10.3
|
||||||
|
|
||||||
|
## [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)
|
## [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)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "trust-graph-wasm"
|
name = "trust-graph-wasm"
|
||||||
version = "0.4.3"
|
version = "0.4.11"
|
||||||
authors = ["Fluence Labs"]
|
authors = ["Fluence Labs"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "trust graph wasm"
|
description = "trust graph wasm"
|
||||||
@ -12,16 +12,16 @@ name = "trust-graph"
|
|||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
trust-graph = { version = "0.4.3", path = "../trust-graph" }
|
trust-graph = { version = "0.4.11", path = "../trust-graph" }
|
||||||
fluence-keypair = { version = "0.10.1", path = "../keypair" }
|
fluence-keypair = { version = "0.10.4", path = "../keypair" }
|
||||||
marine-rs-sdk = { version = "0.7.1", features = ["logger"] }
|
marine-rs-sdk = { version = "0.10.2", features = ["logger"] }
|
||||||
marine-sqlite-connector = "0.8.0"
|
marine-sqlite-connector = "0.9.2"
|
||||||
|
|
||||||
libp2p-identity = { workspace = true }
|
libp2p-identity = { workspace = true }
|
||||||
|
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
anyhow = "1.0.31"
|
anyhow = "1.0.31"
|
||||||
once_cell = "1.4.1"
|
once_cell = "1.18.0"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
bs58 = "0.4.0"
|
bs58 = "0.4.0"
|
||||||
rmp-serde = "1.1.1"
|
rmp-serde = "1.1.1"
|
||||||
@ -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.9.1"
|
marine-rs-sdk-test = "0.12.1"
|
||||||
rusqlite = "0.28.0"
|
rusqlite = "0.28.0"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
marine-rs-sdk-test = "0.9.1"
|
marine-rs-sdk-test = "0.12.1"
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
modules_dir = "artifacts/"
|
modules_dir = "artifacts/"
|
||||||
|
total_memory_limit = "Infinity"
|
||||||
|
|
||||||
[[module]]
|
[[module]]
|
||||||
name = "sqlite3"
|
name = "sqlite3"
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
set -o errexit -o nounset -o pipefail
|
set -o errexit -o nounset -o pipefail
|
||||||
|
set -x
|
||||||
|
|
||||||
# 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")"
|
||||||
@ -13,7 +15,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/sqlite-wasm-v0.18.1/sqlite3.wasm -o artifacts/sqlite3.wasm
|
curl -sS -L https://github.com/fluencelabs/sqlite/releases/download/sqlite-wasm-v0.18.2/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
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "nightly-2022-12-06"
|
channel = "nightly-2023-12-06"
|
||||||
targets = [ "x86_64-apple-darwin", "wasm32-wasi", "wasm32-unknown-unknown", "x86_64-unknown-linux-gnu" ]
|
targets = [ "x86_64-apple-darwin", "wasm32-wasi", "wasm32-unknown-unknown", "x86_64-unknown-linux-gnu" ]
|
||||||
|
@ -37,7 +37,7 @@ pub(crate) fn check_timestamp_tetraplets(
|
|||||||
.get(arg_number)
|
.get(arg_number)
|
||||||
.ok_or_else(|| InvalidTimestampTetraplet(format!("{:?}", call_parameters.tetraplets)))?;
|
.ok_or_else(|| InvalidTimestampTetraplet(format!("{:?}", call_parameters.tetraplets)))?;
|
||||||
let tetraplet = tetraplets
|
let tetraplet = tetraplets
|
||||||
.get(0)
|
.first()
|
||||||
.ok_or_else(|| InvalidTimestampTetraplet(format!("{:?}", call_parameters.tetraplets)))?;
|
.ok_or_else(|| InvalidTimestampTetraplet(format!("{:?}", call_parameters.tetraplets)))?;
|
||||||
(TRUSTED_TIMESTAMP.eq(&(&tetraplet.service_id, &tetraplet.function_name))
|
(TRUSTED_TIMESTAMP.eq(&(&tetraplet.service_id, &tetraplet.function_name))
|
||||||
&& tetraplet.peer_pk == call_parameters.host_id)
|
&& tetraplet.peer_pk == call_parameters.host_id)
|
||||||
|
@ -4,6 +4,89 @@
|
|||||||
* dependencies
|
* dependencies
|
||||||
* fluence-keypair bumped from 0.10.0 to 0.10.1
|
* fluence-keypair bumped from 0.10.0 to 0.10.1
|
||||||
|
|
||||||
|
## [0.4.11](https://github.com/fluencelabs/trust-graph/compare/trust-graph-v0.4.10...trust-graph-v0.4.11) (2024-01-17)
|
||||||
|
|
||||||
|
|
||||||
|
### Miscellaneous Chores
|
||||||
|
|
||||||
|
* **trust-graph:** Synchronize trust-graph, wasm and api versions
|
||||||
|
|
||||||
|
## [0.4.10](https://github.com/fluencelabs/trust-graph/compare/trust-graph-v0.4.9...trust-graph-v0.4.10) (2024-01-03)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **trust-graph:** Revert release 0.4.10 ([#153](https://github.com/fluencelabs/trust-graph/issues/153)) ([b263ce1](https://github.com/fluencelabs/trust-graph/commit/b263ce1fb13b937b629608ede35b6f436023dcac))
|
||||||
|
|
||||||
|
## [0.4.9](https://github.com/fluencelabs/trust-graph/compare/trust-graph-v0.4.8...trust-graph-v0.4.9) (2023-12-28)
|
||||||
|
|
||||||
|
|
||||||
|
### Miscellaneous Chores
|
||||||
|
|
||||||
|
* **trust-graph:** Synchronize trust-graph, wasm and api versions
|
||||||
|
|
||||||
|
## [0.4.8](https://github.com/fluencelabs/trust-graph/compare/trust-graph-v0.4.7...trust-graph-v0.4.8) (2023-12-20)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* update marine sdk's, configs and sqlite connector ([#129](https://github.com/fluencelabs/trust-graph/issues/129)) ([0b66f4e](https://github.com/fluencelabs/trust-graph/commit/0b66f4e0536633879de46f69ac8391c72ece7e77))
|
||||||
|
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
* The following workspace dependencies were updated
|
||||||
|
* dependencies
|
||||||
|
* fluence-keypair bumped from 0.10.3 to 0.10.4
|
||||||
|
|
||||||
|
## [0.4.7](https://github.com/fluencelabs/trust-graph/compare/trust-graph-v0.4.6...trust-graph-v0.4.7) (2023-07-04)
|
||||||
|
|
||||||
|
|
||||||
|
### Miscellaneous Chores
|
||||||
|
|
||||||
|
* **trust-graph:** Synchronize trust-graph, wasm and api versions
|
||||||
|
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
* The following workspace dependencies were updated
|
||||||
|
* dependencies
|
||||||
|
* fluence-keypair bumped from 0.10.2 to 0.10.3
|
||||||
|
|
||||||
|
## [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)
|
## [0.4.3](https://github.com/fluencelabs/trust-graph/compare/trust-graph-v0.4.2...trust-graph-v0.4.3) (2023-05-08)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "trust-graph"
|
name = "trust-graph"
|
||||||
version = "0.4.3"
|
version = "0.4.11"
|
||||||
authors = ["Fluence Labs"]
|
authors = ["Fluence Labs"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "trust graph"
|
description = "trust graph"
|
||||||
@ -10,12 +10,12 @@ repository = "https://github.com/fluencelabs/trust-graph"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
serde = { version = "1.0.118", features = ["derive"] }
|
serde = { version = "1.0.118", features = ["derive"] }
|
||||||
|
|
||||||
fluence-keypair = { path = "../keypair", version = "0.10.1" }
|
fluence-keypair = { path = "../keypair", version = "0.10.4" }
|
||||||
bs58 = "0.4.0"
|
bs58 = "0.4.0"
|
||||||
failure = "0.1.6"
|
failure = "0.1.6"
|
||||||
log = "0.4.11"
|
log = "0.4.11"
|
||||||
ref-cast = "1.0.2"
|
ref-cast = "1.0.2"
|
||||||
derivative = "2.1.1"
|
derivative = "2.2.0"
|
||||||
thiserror = "1.0.23"
|
thiserror = "1.0.23"
|
||||||
sha2 = "0.10.6"
|
sha2 = "0.10.6"
|
||||||
nonempty = "0.8.1"
|
nonempty = "0.8.1"
|
||||||
|
@ -29,7 +29,7 @@ use std::{
|
|||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct PublicKeyHashable(PublicKey);
|
pub struct PublicKeyHashable(PublicKey);
|
||||||
|
|
||||||
#[allow(clippy::derive_hash_xor_eq)]
|
#[allow(clippy::derived_hash_with_manual_eq)]
|
||||||
impl Hash for PublicKeyHashable {
|
impl Hash for PublicKeyHashable {
|
||||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||||
state.write(&self.0.encode());
|
state.write(&self.0.encode());
|
||||||
|
@ -154,7 +154,7 @@ where
|
|||||||
C: Borrow<Certificate>,
|
C: Borrow<Certificate>,
|
||||||
{
|
{
|
||||||
let chain = &cert.borrow().chain;
|
let chain = &cert.borrow().chain;
|
||||||
let mut issued_by = chain.get(0).ok_or(EmptyChain)?.issued_for.clone();
|
let mut issued_by = chain.first().ok_or(EmptyChain)?.issued_for.clone();
|
||||||
|
|
||||||
// TODO: optimize to check only root weight
|
// TODO: optimize to check only root weight
|
||||||
for trust in chain {
|
for trust in chain {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user