Skip to content

Commit

Permalink
chore(README): add examples and update roadmap
Browse files Browse the repository at this point in the history
  • Loading branch information
RTann committed Jun 16, 2024
1 parent 2d03310 commit 28ae451
Showing 1 changed file with 92 additions and 4 deletions.
96 changes: 92 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,98 @@ APIs similar to the source repository.

Only libsignal-protocol is implemented at this time.

This repository is still under development, so
breaking changes should be expected.
This repository is still under development, so users should expect
breaking changes.

## How to Use

### Protocol

#### Session

```go
package main

import (
"context"
"crypto/rand"

"github.com/RTann/libsignal-go/protocol/address"
"github.com/RTann/libsignal-go/protocol/identity"
"github.com/RTann/libsignal-go/protocol/session"
)

// Alice creates a session with Bob and sends a message.
// Error handing is ignored in this example, but should otherwise not be ignored.
func main() {
keyPair, _ := identity.GenerateKeyPair(rand.Reader)
registrationID := uint32(1)
bobAddress := address.Address{
Name: "+15555555555",
DeviceID: 1,
}

// Alice creates a session to talk to Bob.
aliceSession := &session.Session{
RemoteAddress: bobAddress,
SessionStore: session.NewInMemStore(),
IdentityKeyStore: identity.NewInMemStore(keyPair, registrationID),
}
// Write a nice encrypted message to Bob.
plaintext := []byte("Hello, Bob!")
aliceCiphertext, _ := aliceSession.EncryptMessage(context.Background(), plaintext)

// Alice sends her encrypted message to Bob.
}
```

```go
package main

import (
"context"
"crypto/rand"

"github.com/RTann/libsignal-go/protocol/address"
"github.com/RTann/libsignal-go/protocol/identity"
"github.com/RTann/libsignal-go/protocol/session"
)

// Bob creates a session with Alice and receives a message.
// Error handing is ignored in this example, but should otherwise not be ignored.
func main() {
keyPair, _ := identity.GenerateKeyPair(rand.Reader)
registrationID := uint32(1)
aliceAddress := address.Address{
Name: "+15555555556",
DeviceID: 1,
}

// Bob creates a session to talk to Alice.
bobSession := &session.Session{
RemoteAddress: bobAddress,
SessionStore: session.NewInMemStore(),
IdentityKeyStore: identity.NewInMemStore(keyPair, registrationID),
}

var ciphertext []byte
// Bob receives Alice's message and stores it in ciphertext.

plaintext, _ := bobSession.DecryptMessage(context.Background(), rand.Reader, ciphertext)

// Alice sends her encrypted message to Bob.
}
```

#### Group Session

```go

```

## Roadmap

* Add and refactor tests
* Implement other APIs available in the source repository.
1. Implement post-quantum cryptography support.
1. Implement sealed sender support.
1. Add and refactor tests.
1. Implement other APIs available in the source repository.

0 comments on commit 28ae451

Please sign in to comment.