Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: updated signature method according to the up-to-date implementation #175

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 1 addition & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ which Pando subscribes.
#### Prerequisite
Pando accepts IPLD data from metadata providers with the following required IPLD children nodes:
1. `Provider String` - provider's peer ID
2. `Signature Bytes` - signature of the IPLD data: sign( bytes(PreviousID) . bytes(Payload) . bytes(Provider)) )
2. `Signature Bytes` - signature of the IPLD data: dagjson.Encode( ipld.Node{PreviousID, Provider, Payload} ).Bytes()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sig, err := SignWithPrivky(signKey, meta)
if err != nil {
	return nil, err
}

// Add signature
meta.Signature = sig

Signature Bytes is bytes from envelop's Marshal(). The envelop will use metaSignatureRecord, PrivateKey and bytes from IPLD node(dagjson.Encode)

// Signs metadata using libp2p envelope
func SignWithPrivky(privkey crypto.PrivKey, meta *Metadata) ([]byte, error) {
metaID, err := signMetadata(meta)
if err != nil {
return nil, err
}
envelope, err := record.Seal(&metaSignatureRecord{metaID: metaID}, privkey)
if err != nil {
return nil, err
}
return envelope.Marshal()
}

3. `Payload Bytes` - bytes of your serialized metadata

and a nullable node:
Expand Down Expand Up @@ -270,46 +270,6 @@ Show information of Pando server

```

### /pando/subscribe
Let Pando subscribe a topic with provider to start metadata synchronization
```shell
./pando-client -a http://127.0.0.1:9000 pando subscribe --provider-peerid 12D3KooWSS3sEujyAXB9SWUvVtQZmxH6vTi9NitqaaRQoUjeEk3M

{
"code": 200,
"message": "subscribe success",
"Data": null
}

```

### /provider/register
Provider should be registered before using Pando service
```shell
./pando-client -a http://127.0.0.1:9000 provider register \
--peer-id 12D3KooWBckWLKiYoUX4k3HTrbrSe4DD5SPNTKgP6vKTva1NaRkJ \
--private-key CAESQLypOCKYR7HGwVl4ngNhEqMZ7opchNOUA4Qc1QDpxsARGr2pWUgkXFXKU27TgzIHXqw0tXaUVx2GIbUuLitq22c= \
--addresses /ip4/127.0.0.1/tcp/9999

{
"code": 200,
"message": "register success",
"Data": null
}

```

to generate an envelop-data only, run:
```shell
./pando-client -a http://127.0.0.1:9000 provider register \
--only-envelop \
--peer-id 12D3KooWBckWLKiYoUX4k3HTrbrSe4DD5SPNTKgP6vKTva1NaRkJ \
--private-key CAESQLypOCKYR7HGwVl4ngNhEqMZ7opchNOUA4Qc1QDpxsARGr2pWUgkXFXKU27TgzIHXqw0tXaUVx2GIbUuLitq22c= \
--addresses /ip4/127.0.0.1/tcp/9999

envelop data saved at ./envelop.data
```

### /metadata/list
List all cids of metadata snapshots
```shell
Expand Down