-
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
179 additions
and
11 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,22 @@ | ||
# Introduction | ||
|
||
Collection of libraries to build fast and secure `nostr` application on `desktop`, `mobile` and `web` environments. | ||
|
||
## Libraries | ||
|
||
* [Nostr](./nostr/01-index.md): Implementation of the `nostr` protocol | ||
* [Nostr SDK](./nostr-sdk/01-index.md): High level nostr client library | ||
|
||
## State | ||
|
||
**These libraries are in ALPHA state**, things that are implemented generally work but the API will change in breaking ways. | ||
|
||
## License | ||
|
||
This project is distributed under the MIT software license. | ||
|
||
## Donations | ||
|
||
⚡ Tips: <https://getalby.com/p/yuki> | ||
|
||
⚡ Lightning Address: [email protected] |
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 |
---|---|---|
@@ -1 +1,10 @@ | ||
# Nostr SDK | ||
|
||
This section include documentation for the `nostr-sdk` library for all the supported languages (Rust, Python, Swift and Kotlin). | ||
|
||
This library depends on `nostr` library so, before continue, take a look to the [`nostr`](../nostr/01-index.md) docs. | ||
|
||
If you're writing a typical Nostr client or bot, this is likely the library you need. | ||
|
||
However, the library is designed in a modular way and depends on several | ||
other lower-level crates. If you're attempting something more custom, you might be interested in [`nostr`](../nostr/01-index.md) library. |
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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
# Installing the library | ||
|
||
## Installing the library | ||
|
||
=== "Rust" | ||
|
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Nostr | ||
|
||
This section include documentation for the `nostr` library (all supported languages). | ||
This section include documentation for the `nostr` library for all the supported languages (Rust, Python, Swift and Kotlin). | ||
|
||
If you're writing a typical Nostr client or bot, you may be interested in [nostr-sdk](../nostr-sdk/01-index.md). |
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 |
---|---|---|
@@ -1,2 +1,21 @@ | ||
## Features | ||
# Features | ||
|
||
!!! note | ||
This page is related **only** to the `rust` library. | ||
|
||
Available features: | ||
|
||
| Feature | Default | Description | | ||
| ------------------- | :-----: | ---------------------------------------------------------------------------------------- | | ||
| `std` | Yes | Enable `std` library | | ||
| `alloc` | No | Needed to use this library in `no_std` context | | ||
| `blocking` | No | Needed to use `NIP-05` and `NIP-11` features in not async/await context | | ||
| `all-nips` | Yes | Enable all NIPs | | ||
| `nip03` | No | Enable NIP-03: OpenTimestamps Attestations for Events | | ||
| `nip04` | Yes | Enable NIP-04: Encrypted Direct Message | | ||
| `nip05` | Yes | Enable NIP-05: Mapping Nostr keys to DNS-based internet identifiers | | ||
| `nip06` | Yes | Enable NIP-06: Basic key derivation from mnemonic seed phrase | | ||
| `nip11` | Yes | Enable NIP-11: Relay Information Document | | ||
| `nip44` | No | Enable NIP-44: Encrypted Payloads (Versioned) - EXPERIMENTAL | | ||
| `nip46` | Yes | Enable NIP-46: Nostr Connect | | ||
| `nip47` | Yes | Enable NIP-47: Nostr Wallet Connect | |
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,103 @@ | ||
# Keys | ||
|
||
## Generate new random keys | ||
|
||
=== "Rust" | ||
|
||
```rust | ||
use nostr::prelude::*; | ||
|
||
fn main() -> Result<()> { | ||
let keys = Keys::generate(); | ||
let public_key = keys.public_key(); | ||
let secret_key = keys.secret_key()?; | ||
|
||
println!("Public key (hex): {}", public_key); | ||
println!("Public key (bech32): {}", public_key.to_bech32()?); | ||
println!("Secret key (hex): {}", keys.secret_key()?.display_secret()); | ||
println!("Secret key (bech32): {}", secret_key.to_bech32()?); | ||
} | ||
``` | ||
|
||
=== "Python" | ||
|
||
```python | ||
from nostr_protocol import Keys | ||
|
||
keys = Keys.generate() | ||
public_key = keys.public_key() | ||
secret_key = keys.secret_key() | ||
print("Keys:") | ||
print(" Public keys:") | ||
print(f" hex: {public_key.to_hex()}") | ||
print(f" bech32: {public_key.to_bech32()}") | ||
print(" Secret keys:") | ||
print(f" hex: {secret_key.to_hex()}") | ||
print(f" bech32: {secret_key.to_bech32()}") | ||
``` | ||
|
||
=== "Kotlin" | ||
|
||
```kotlin | ||
TODO | ||
``` | ||
|
||
=== "Swift" | ||
|
||
``` swift | ||
TODO | ||
``` | ||
|
||
## Restore from **hex** and/or **bech32** secret key | ||
|
||
=== "Rust" | ||
|
||
```rust | ||
use std::str::FromStr; | ||
|
||
use nostr::prelude::*; | ||
|
||
fn main() -> Result<()> { | ||
// Restore from hex | ||
let secret_key = SecretKey::from_str("6b911fd37cdf5c81d4c0adb1ab7fa822ed253ab0ad9aa18d77257c88b29b718e")?; | ||
let keys = Keys::new(secret_key); | ||
|
||
// Restore from bech32 | ||
let secret_key = SecretKey::from_bech32("nsec1j4c6269y9w0q2er2xjw8sv2ehyrtfxq3jwgdlxj6qfn8z4gjsq5qfvfk99")?; | ||
let keys = Keys::new(secret_key); | ||
|
||
// Try from bech32 or hex | ||
let keys = Keys::from_sk_str("hex or bech32 secret key")?; | ||
|
||
// ... | ||
} | ||
``` | ||
|
||
=== "Python" | ||
|
||
```python | ||
from nostr_protocol import * | ||
|
||
secret_key = SecretKey.from_hex("6b911fd37cdf5c81d4c0adb1ab7fa822ed253ab0ad9aa18d77257c88b29b718e") | ||
keys = Keys(secret_key) | ||
|
||
secret_key = SecretKey.from_bech32("nsec1j4c6269y9w0q2er2xjw8sv2ehyrtfxq3jwgdlxj6qfn8z4gjsq5qfvfk99") | ||
keys = Keys(secret_key) | ||
|
||
keys = Keys.from_sk_str("hex or bech32 secret key") | ||
|
||
# .. | ||
``` | ||
|
||
=== "Kotlin" | ||
|
||
```kotlin | ||
TODO | ||
``` | ||
|
||
=== "Swift" | ||
|
||
``` swift | ||
TODO | ||
``` |
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