LibXMTP is a shared library encapsulating the core functionality of the XMTP messaging protocol, such as cryptography, networking, and language bindings.
Originally posted by **jac18281828** October 23, 2023
### Installation Management
`grantInstallation(wallet, keyBundle, metadata)`
Declares that an installation is associated with a wallet. Currently, we do this by signing the installation’s keys using the wallet’s keys.
In v3, an installation has two keys, a Curve25519 + Ed25519 key. In MLS, the keys may be different, but the overall concept is the same.
One day we might consider adding an expiry date for the grant, before which it must be renewed.
#### Pseudo Implementation
```
function saveAttribute(web3, name, value, validity) {
signature_message = ['setAttribute', name, value, validity]
owner_nonce = web3.call('nonce()')
digest_payload = [ 0x19, 0, registry_address, owner_nonce, public_key, signature_message ]
digest = keccak256(digest_payload)
(sigV, sigR, sigS) = wallet.sign(digest)
didReg = web3.contract(registry_address)
didReg.send('setAttributeSigned', [public_key, sigV, sigR, sigS, name, value, validity])
}
function saveInstallation() {
web3 = new JsonRpc(RPC_URL, Network)
install_key = generate_install_key()
did = `did:xmtp:${did_id}`
saveAttribute(web3, 'did:xmtp:v3:installkey', install_key)
saveAttribute(web3, 'did:xmtp:v3:did, did)
}
```
#### Required Configuration
```
Network := MAINNET | TESTNET
RPC_URL = Ethereum node url
REGISTRY_ADDRESS
Discussed in https://github.com/xmtp/libxmtp/discussions/274