Skip to content

Commit d64fc0e

Browse files
committed
update
1 parent bf0a536 commit d64fc0e

File tree

6 files changed

+163
-2
lines changed

6 files changed

+163
-2
lines changed

docs/getting-started.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
Nostr Game Engine is fully modular: you can pick and choose individual engine components from our [GitHub Package Registry](https://github.com/orgs/NostrGameEngine/packages?repo_name=ngengine) and include them in any Gradle project.
1+
Nostr Game Engine is fully modular: you can pick and choose individual engine components from [Maven Central](https://central.sonatype.com/search?namespace=org.ngengine) and include them in any Gradle project.
2+
3+
!!! tip
4+
You are going to need also this repository
5+
```groovy
6+
repositories {
7+
maven {
8+
url = "https://maven.rblb.it/NostrGameEngine/libdatachannel-java"
9+
}
10+
}
11+
```
12+
that holds a fork of libdatachannel-java used by the network module
213

314
However, the quickest way to start development is with the app template, detailed below.
415

docs/network/player.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ A valid gamertag must:
133133
* **Name** (3–21 characters)
134134
* **Discriminator** (4 digits)
135135
2. Use only alphanumeric characters or underscores (`[A-Za-z0-9_]`) in the name.
136-
3. Match the discriminator to the first four characters of the user’s Bech32 key payload (characters 5–8 of the Nostr key).
136+
3. Match the discriminator to the first four characters of the user’s Bech32 public key payload (characters 5–8 of the Nostr public key).
137137

138138
!!! example "Valid Gamertag"
139139
For key `npub1abcd1234…`, a valid gamertag could be `OstrichSlayer#1234`.

docs/nip-drafts/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- [NIP-RTC](nip-RTC.md)
2+
- [NIP-GAMERTAG](nip-GAMERTAG.md)

docs/nip-drafts/nip-GAMERTAG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
NIP-GAMERTAG Gaming Identity
2+
==============
3+
`draft` `optional` `author:riccardobl`
4+
5+
This NIP defines a nip-39 external identity that defines a searchable display name that a Nostr user can choose to represent themselves in games.
6+
---------------------------------
7+
8+
A gamertag is a user-friendly handle that combines a chosen name with a short discriminator.
9+
It’s suitable for display or search, but not as a unique identifier (always use the Nostr public key for security).
10+
11+
A valid gamertag must:
12+
13+
- Have exactly two parts, separated by #:
14+
- Name (3–21 characters)
15+
- Discriminator (4 digits)
16+
- Use only alphanumeric characters or underscores ([A-Za-z0-9_]) in the name.
17+
- Match the discriminator to the first four characters of the user’s Bech32 public key payload (characters 5–8 of the Nostr key).
18+
19+
20+
# `i` tag for gamertags
21+
22+
The gamertag is defined with a nip-39 compliant `i` tag that uses `gamertag` as platform followed by the gamertag itself, and no proof.
23+
24+
For example, a valid gamertag would be represented as:
25+
26+
```
27+
["i", "gamertag:Nostrich#1234"]
28+
```
29+

docs/nip-drafts/nip-RTC.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
NIP-RTC WebRTC
2+
==============
3+
`draft` `optional` `author:jacany` `author:riccardobl`
4+
based on https://github.com/nostr-protocol/nips/blob/ead1cd6ca6b5b789d70e0d146d17266a2e8e2fba/100.md
5+
6+
This NIP defines how to do WebRTC communication over nostr.
7+
---------------------------------
8+
9+
## Defining Rooms
10+
Rooms are essentially the space that you will be connected to.
11+
Rooms are created by generating a random secret key from wich the derived public key is used as the room id.
12+
Event an one to one connection requires a room.
13+
To comunicate with someone in the room the events must use a `r` tag with the room id and a `p` tag with the public key of the person you are trying to connect to.
14+
Some events will require only the `r` tag and as such are broadcasted to the entire room, others require the `p` tag and are sent to a specific person in the room.
15+
16+
Clients MUST listen for both the `r` and `p` tag containing their pubkey so they know that event is intended for them, for the offer, answer and candidate events, and only to the `r` tag for connect and disconnect events.
17+
18+
## Encryption
19+
The `content` field is encrypted with `NIP-44`, twice, first with the conversation key derives by sender priv + receiver pub and then with the conversation key derived by room priv + receiver pub.
20+
21+
Pseudo code:
22+
23+
```javascript
24+
function encrypt(localPrivKey, content, recipientPubkey, roomSecretKey){
25+
const serialized = JSON.stringify(content);
26+
let encrypted = nip44Encrypt(serialized, nip44ConversationKey(localPrivKey, recipientPubkey));
27+
encrypted = nip44Encrypt(encrypted, nip44ConversationKey(roomSecretKey, recipientPubkey));
28+
return encrypted;
29+
}
30+
31+
function decrypt(localPrivKey, content, senderPubkey, roomPublicKey){
32+
content = nip44Decrypt(content, nip44ConversationKey(localPrivKey, roomPublicKey));
33+
content = nip44Decrypt(content, nip44ConversationKey(localPrivKey, senderPubkey));
34+
return JSON.parse(decrypted);
35+
}
36+
```
37+
38+
### Broadcasting that you are present
39+
Announces that the client is ready to connect to others.
40+
The connection ID is inferred from the provided pubkey.
41+
```json
42+
{
43+
"kind": 25050,
44+
"pubkey": "<sender pubkey>",
45+
"tags": [
46+
["t", "connect"],
47+
["r", "room id"]
48+
["expiration", "<expiration>"]
49+
]
50+
}
51+
```
52+
53+
### Closing
54+
This is used when disconnecting from everybody else. Ex: when browser tab is closed.
55+
```json
56+
{
57+
"kind": 25050,
58+
"pubkey": "<sender pubkey>",
59+
"tags": [
60+
["type", "disconnect"],
61+
["r", "room id"]
62+
]
63+
}
64+
```
65+
66+
### Offering to connect
67+
Used when responding to a `type:connect`. Offering to connect to that peer.
68+
```json
69+
{
70+
"kind": 25050,
71+
"pubkey": "<sender pubkey>",
72+
"tags": [
73+
["type", "offer"],
74+
["p", "<reciever>"],
75+
["r", "<room id>"]
76+
],
77+
"content": encrypt({
78+
"offer": "<offer>",
79+
"turn": ["protocol://turnserver:port", "protocol://turnserver2:port"],
80+
...misc
81+
})
82+
}
83+
```
84+
85+
### Answering an Offer
86+
```json
87+
{
88+
"kind": 25050,
89+
"pubkey": "<sender pubkey>",
90+
"tags": [
91+
["type", "answer"],
92+
["p", "<reciever>"],
93+
["r", "<room id>"]
94+
],
95+
"content": encrypt({
96+
"sdp": "<sdp>",
97+
"turn": ["protocol://turnserver:port", "protocol://turnserver2:port"],
98+
...misc
99+
})
100+
}
101+
```
102+
103+
### Broadcasting ICE Candidate
104+
```json
105+
{
106+
"kind": 25050,
107+
"pubkey": "<sender pubkey>",
108+
"tags": [
109+
["type", "candidate"],
110+
["p", "<reciever>"],
111+
["r", "<room id>"]
112+
],
113+
"content": encrypt({
114+
"candidates": ["<sdp>"],
115+
...misc
116+
})
117+
}
118+
```

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ nav:
6363
- Lemur: gui/lemur.md
6464
- Javadoc: https://javadoc.ngengine.org/
6565
- jMonkeyEngine Wiki: https://wiki.jmonkeyengine.org
66+
- NIP Drafts: nip-drafts/index.md
6667

6768
extra_css:
6869
- css/extra.css

0 commit comments

Comments
 (0)