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: export pop command #262

Merged
merged 23 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
1239d92
chore: add pop command
RafilxTenfen Jan 3, 2025
83ef17f
feat: add new command to export pop for finality providers
RafilxTenfen Jan 5, 2025
84f6a9c
chore: removed unnecessary command
RafilxTenfen Jan 5, 2025
b388f50
chore: update struct comments
RafilxTenfen Jan 5, 2025
900f949
chore: add #262 to changelog
RafilxTenfen Jan 5, 2025
e81a87f
chore: update comments
RafilxTenfen Jan 6, 2025
e451da0
chore: address pr comments
RafilxTenfen Jan 6, 2025
59b3022
chore: modified to sign address directly and export the schnirr signa…
RafilxTenfen Jan 6, 2025
ceecf9f
Merge branch 'main' of github.com:babylonlabs-io/finality-provider in…
RafilxTenfen Jan 6, 2025
6140234
chore: remove unnecessary addr convertion
RafilxTenfen Jan 6, 2025
cbf9a07
chore: remove bad comment
RafilxTenfen Jan 6, 2025
91dca21
chore: modified to sign the bbn address as string direclty
RafilxTenfen Jan 6, 2025
4959109
chore: update pop export structure naming accordingly to fp data
RafilxTenfen Jan 6, 2025
bb08082
chore: add public functions to verify signature, allowing import to e…
RafilxTenfen Jan 6, 2025
56f7a39
fix: lint
RafilxTenfen Jan 6, 2025
4515a79
chore: moved json attributes to more fp like naming
RafilxTenfen Jan 6, 2025
cc07bcd
chore: add func to verify the PopExport
RafilxTenfen Jan 6, 2025
0793189
chore: draft spec
RafilxTenfen Jan 6, 2025
6135525
chore: modify spec to reflect new json naming
RafilxTenfen Jan 6, 2025
a77fc9f
fix: ineffectual assignment
RafilxTenfen Jan 6, 2025
c1a77bf
chore: address pr comments
RafilxTenfen Jan 6, 2025
120b21e
Merge branch 'main' of github.com:babylonlabs-io/finality-provider in…
RafilxTenfen Jan 7, 2025
c409bef
chore: rollback nonamedreturns and modify previr of Verify to Valid
RafilxTenfen Jan 7, 2025
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## Unreleased

### Improvements

* [#251](https://github.com/babylonlabs-io/finality-provider/pull/251) Add nlreturn lint
* [#252](https://github.com/babylonlabs-io/finality-provider/pull/252) Remove interceptors and use context
* [#266](https://github.com/babylonlabs-io/finality-provider/pull/266) Change default config
* [#262](https://github.com/babylonlabs-io/finality-provider/pull/262) Add new command to export pop

## v0.14.3

Expand Down
80 changes: 80 additions & 0 deletions docs/pop_format_spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Proof of Possession (PoP) Specification

## Overview

The Proof of Possession (PoP) structured specification outlined in this
document allows for the verification of the mutual ownership of a Babylon
key pair and an EOTS key pair. In the following, we outline the five essential
attributes exposed by the `PoPExport` structure and provide examples and
validation procedures.

## Attributes

The `PoPExport` structure is defined bellow:

```go
// PoPExport the data needed to prove ownership of the eots and babylon key pairs.
type PoPExport struct {
// Btc public key is the EOTS PK *bbntypes.BIP340PubKey marshal hex
EotsPublicKey string `json:"eotsPublicKey"`
// Babylon public key is the *secp256k1.PubKey marshal hex
BabyPublicKey string `json:"babyPublicKey"`

// Babylon key pair signs EOTS public key as hex
BabySignEotsPk string `json:"babySignEotsPk"`
// Schnorr signature of EOTS private key over the SHA256(Baby address)
EotsSignBaby string `json:"eotsSignBaby"`

// Babylon address ex.: bbn1f04czxeqprn0s9fe7kdzqyde2e6nqj63dllwsm
BabyAddress string `json:"babyAddress"`
}
```

Detailed specification of each field:

- `EotsPublicKey`: The EOTS public key of the finality provider in hexadecimal format.
- `BabyPublicKey` – The Babylon secp256k1 public key in base64 format.
- `BabyAddress` – The Babylon account address (`bbn` prefix). The address is
derived from the `BabyPublicKey` and used as the primary identifier on the
Babylon network.
- `EotsSignBaby` – A Schnorr signature in base64 format, created by signing the
`sha256(BabyAddress)` with the EOTS private key.
- `BabySignEotsPk` – A signature of the `EotsPublicKey`, created by the Babylon
private key. This signature follows the Cosmos
[ADR-036](https://github.com/cosmos/cosmos-sdk/blob/main/docs/architecture/adr-036-arbitrary-signature.md)
specification and is encoded in base64.

## Example

Below is an example JSON representation of the PoPExport structure:

```json
{
"eotsPublicKey": "3d0bebcbe800236ce8603c5bb1ab6c2af0932e947db4956a338f119797c37f1e",
"babyPublicKey": "A0V6yw74EdvoAWVauFqkH/GVM9YIpZitZf6bVEzG69tT",
"babySignEotsPk": "AOoIG2cwC2IMiJL3OL0zLEIUY201X1qKumDr/1qDJ4oQvAp78W1nb5EnVasRPQ/XrKXqudUDnZFprLd0jaRJtQ==",
"eotsSignBaby": "pR6vxgU0gXq+VqO+y7dHpZgHTz3zr5hdqXXh0WcWNkqUnRjHrizhYAHDMV8gh4vks4PqzKAIgZ779Wqwf5UrXQ==",
"babyAddress": "bbn1f04czxeqprn0s9fe7kdzqyde2e6nqj63dllwsm"
}
```

## Validation

The function responsible for validating the `PoPExport` is `VerifyPopExport`,
which can be found [here](https://github.com/babylonlabs-io/finality-provider/blob/cc07bcd4dc434f7095668724aad6865bffe425e0/eotsmanager/cmd/eotsd/daemon/pop.go#L211).

`VerifyPopExport` ensures the authenticity and integrity of the `PoPExport`
by cross-verifying the provided signatures and public keys. This process
consists of two core validation steps:

- `ValidEotsSignBaby` – This function checks the validity of the Schnorr
signature `(EotsSignBaby)` by verifying that the EOTS private key has correctly
signed the SHA256 hash of the BABY address.
- `ValidBabySignEots` – This function confirms that the BABY private key has
signed the EOTS public key `(EotsPublicKey)`, ensuring mutual validation
between the key pairs.

If both signatures pass verification, the export is deemed valid, confirming
that the finality provider holds both key pairs. This function plays a critical
role in maintaining trust and security in the finality provider's key
management process.
3 changes: 3 additions & 0 deletions eotsmanager/cmd/eotsd/daemon/flags.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package daemon

const (
keyNameFlag = "key-name"
eotsPkFlag = "eots-pk"
passphraseFlag = "passphrase"
forceFlag = "force"
rpcListenerFlag = "rpc-listener"
rpcClientFlag = "rpc-client"
Expand Down
Loading
Loading