Tamper-proof operations
The component in charge of state handling is the . To set up the stateService
3 interfaces need to be implemented and provided to the StateService
constructor:
Cache
interface in thecache
package. Standard cache.NewFileCache provides a file state store solution.StateProvider
in thestateService
package. It provides a fresh state from immudb server when the client is being initialized for the first time. Standard StateProvider provides a service that retrieve immudb first state hash from a gRPC endpoint.UUIDProvider
in thestateService
package. It provides the immudb identifier. This is needed to allow the client to safely connect to multiple immudb instances. Standard UUIDProvider provides the immudb server identifier from a gRPC endpoint.
Following an example how to obtain a client instance with a custom state service.
Any immudb server has its own UUID. This is exposed as part of the login response. Java SDK can use any implementation of the ImmuStateHolder
interface, which specifies two methods:
ImmuState getState(String serverUuid, String database)
for getting a state.void setState(String serverUuid, ImmuState state)
for setting a state.
Note that a state is related to a specific database (identified by its name) and a server (identified by the UUID). Currently, Java SDK offers two implementations of this interface for storing and retriving a state:
FileImmuStateHolder
that uses a disk file based store.SerializableImmuStateHolder
that uses an in-memory store.
As most of the code snippets include FileImmuStateHolder
, please find below an example using the in-memory alternative:
SerializableImmuStateHolder stateHolder = new SerializableImmuStateHolder();
ImmuClient immuClient = ImmuClient.newBuilder()
.withStateHolder(stateHolder)
.withServerUrl("localhost")
.withServerPort(3322)
.build();
immuClient.login("immudb", "immudb");
immuClient.useDatabase("defaultdb");
// ...
immuClient.logout();
This feature is not yet supported or not documented. Do you want to make a feature request or help out? Open an issue on Node.js sdk github project (opens new window)
This feature is not yet supported or not documented. Do you want to make a feature request or help out? Open an issue on
If you’re using another development language, please read up on our immugw (opens new window) option.
If immudb
is launched with a private signing key, each signed request can be verified with the public key. In this way the identity of the server can be proven. Check to see how to generate a valid key.
// Having immudb server running with state signature enabled
// we provision the client with the public key file, and this implies that
// state signature verification is done on the client side
File publicKeyFile = new File("path/to/public_key.pem");
immuClient = ImmuClient.newBuilder()
.withServerUrl("localhost")
.withServerPort(3322)
.withServerSigningKey(publicKeyFile.getAbsolutePath())
.build();
try {
ImmuState state = immuClient.currentState();
// It should all be ok as long as the immudb server has been started with
// state signature feature enabled, otherwise, this verification will fail.
} catch (RuntimeException e) {
// State signature failed.
}
This feature is not yet supported or not documented. Do you want to make a feature request or help out? Open an issue on Python sdk github project (opens new window)
If you’re using another development language, please read up on our option.
Tamperproof reading and writing
You can read and write records securely using a built-in cryptographic verification.
Verified get and set
The client implements the mathematical validations, while your application uses a traditional read or write function.
tx, err := client.VerifiedSet(ctx, []byte(`hello`), []byte(`immutable world`))
if err != nil {
log.Fatal(err)
}
fmt.Printf("Successfully committed and verified tx %d\n", tx.Id)
entry, err := client.VerifiedGet(ctx, []byte(`hello`))
log.Fatal(err)
fmt.Printf("Successfully retrieved and verified entry: %v\n", entry)
This feature is not yet supported or not documented. Do you want to make a feature request or help out? Open an issue on Python sdk github project (opens new window)
import ImmudbClient from 'immudb-node'
import Parameters from 'immudb-node/types/parameters'
const IMMUDB_HOST = '127.0.0.1'
const IMMUDB_PORT = '3322'
const IMMUDB_USER = 'immudb'
const IMMUDB_PWD = 'immudb'
const cl = new ImmudbClient({ host: IMMUDB_HOST, port: IMMUDB_PORT });
(async () => {
await cl.login({ user: IMMUDB_USER, password: IMMUDB_PWD })
const verifiedSetReq: Parameters.VerifiedSet = {
key: 'hello',
value: 'world',
}
const verifiedSetRes = await cl.verifiedSet(verifiedSetReq)
console.log('success: verifiedSet', verifiedSetRes)
const verifiedGetReq: Parameters.VerifiedGet = {
key: 'hello',
}
const verifiedGetRes = await cl.verifiedGet(verifiedGetReq)
This feature is not yet supported or not documented. Do you want to make a feature request or help out? Open an issue on