-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add notaryd
#61
Merged
Merged
Add notaryd
#61
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// This file is Copyright its original authors, visible in version control | ||
// history. | ||
// | ||
// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE | ||
// or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. | ||
// You may not use this file except in accordance with one or both of these | ||
// licenses. | ||
|
||
use civkitservice::civkit_service_client::CivkitServiceClient; | ||
|
||
use civkitservice::{RegisterRequest, RegisterReply}; | ||
|
||
use bitcoin::secp256k1::{SecretKey, PublicKey, Secp256k1}; | ||
use bitcoin::secp256k1; | ||
|
||
pub mod civkitservice { | ||
tonic::include_proto!("civkitservice"); | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
|
||
let mut civkitd_client = CivkitServiceClient::connect(format!("http://[::1]:{}", 50031)).await?; | ||
|
||
let secp_ctx = Secp256k1::new(); | ||
let pubkey = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42;32]).unwrap()); | ||
|
||
let request = tonic::Request::new(RegisterRequest { | ||
service_pubkey: pubkey.serialize().to_vec() | ||
}); | ||
|
||
let response = civkitd_client.register_service(request).await?; | ||
|
||
//TODO: step 1 receive queries from Nostr client | ||
// - add new event kind `service payload` | ||
// - add mainstay / opentimestamp attestations in nostr event content | ||
|
||
//TODO: step 2 store attestation in local service store | ||
// - add a map | ||
|
||
//TODO: step 3 have the notary server counter-sign the attestation (+ maybe add block hash) | ||
|
||
//TODO: step 4 build a merkle tree or pay-to-contract with the attestation | ||
|
||
//TODO: step 5 commit the notarization anchor in a Bitcoin on-chain transaction when X is reached | ||
// - X is the frequency declared in the "service policy" at register_service | ||
|
||
//TODO: step 6 broadcast the on-chain transaction | ||
|
||
//TODO: step 7 return the result to the Nostr client ? | ||
// - add pre-notification at step 3 if the client does not want to be dependent | ||
// on blockchain interval | ||
|
||
Ok(()) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirming my understanding of the process flow in pseudo-code
fn notarize(service_payload) -> NostrEventContent {
2. local_store.append(service_payload)
3. attestation = sign(service_payload) // pre-notification?
4. build_merkle_tree // unclear as to process here
5. if local_store.length() >= x; btcx = create_btc_transaction(local_store);
6. broadcast(btcx);
7. return NostrEventContent(attestation);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the flow is mostly correct with the following feedback:
4. I don’t know yet if the attestation will be committed with a merkle tree or pay-to-contract (i’m thinking to start to standardize bitcoin notarization with bips or something equivalent to have inter-operability of attestations)
5. rather to have
create_btc_transaction
committed on the size of the store, X should be a time point (block height or unix epoch) though obviously we might have to flush when the store is full before X