> ## Documentation Index
> Fetch the complete documentation index at: https://sava.software/llms.txt
> Use this file to discover all available pages before exploring further.

# Core

> Common Solana Cryptography & Serialization Utilities.

<Card title="GitHub Repository" icon="github" horizontal={true} href="https://github.com/sava-software/sava" />

## [Dependencies](https://github.com/sava-software/sava/blob/main/sava-core/src/main/java/module-info.java)

* [org.bouncycastle.provider](https://www.bouncycastle.org/download/bouncy-castle-java/#latest)

## Features

* [Transaction (de)serialization](#transaction-deserialization)
* [Account Types:](https://github.com/sava-software/sava/tree/main/sava-core/src/main/java/software/sava/core/accounts)
  * Token, Mint, Token2022 and extensions
  * Address Lookup Tables
  * Sysvar
    * Clock
    * EpochRewards
* [Common collection of main-net addresses](https://github.com/sava-software/sava/tree/main/sava-core/src/main/java/software/sava/core/accounts/SolanaAccounts.java)
* Ed25519 [public](https://github.com/sava-software/sava/tree/main/sava-core/src/main/java/software/sava/core/accounts/PublicKey.java) and [private](https://github.com/sava-software/sava/tree/main/sava-core/src/main/java/software/sava/core/accounts/Signer.java) keys
* Program derived addresses
* [Borsh (de)serialization](https://github.com/sava-software/sava/tree/main/sava-core/src/main/java/software/sava/core/borsh/Borsh.java)
* [Encoding:](https://github.com/sava-software/sava/tree/main/sava-core/src/main/java/software/sava/core/encoding)
  * [Base58](https://github.com/sava-software/sava/tree/main/sava-core/src/main/java/software/sava/core/encoding/Base58.java)
  * [Hex](https://github.com/sava-software/sava/tree/main/sava-core/src/main/java/software/sava/core/encoding/Jex.java)
  * [Little Endian Numbers](https://github.com/sava-software/sava/tree/main/sava-core/src/main/java/software/sava/core/encoding/ByteUtil.java)
  * [Compact u16](https://github.com/sava-software/sava/tree/main/sava-core/src/main/java/software/sava/core/encoding/CompactU16Encoding.java)

## Private Key Parsing

### Usage

```java theme={null}
var jsonConfig = "";
var ji = JsonIterator.parse(jsonConfig);
var signer = PrivateKeyEncoding.fromJsonPrivateKey(ji);
```

### JSON Configuration

If the base58 encoded public key is configured via `pubKey` it will be used to further validate the public key derived
from the private key.

#### Solana CLI Key Pair JSON Array

By default, if only an array is configured, the assumption is that it is a key pair generated by the Solana CLI.

```
[1,2,3, ... ,42]
```

#### JSON Array

```json theme={null}
{
  "pubKey": "<BASE58_ENCODED_PUBLIC_KEY>",
  "encoding": "jsonKeyPairArray",
  "secret": []
}
```

#### Key Pair

Encoded 64 byte private/public key pair. Derived public key will be validated.

* base64KeyPair
* base58KeyPair

```json theme={null}
{
  "pubKey": "<BASE58_ENCODED_PUBLIC_KEY>",
  "encoding": "base64KeyPair",
  "secret": "asdf=="
}
```

#### Private Key Only

Encoded 32 byte private key.

* base64PrivateKey
* base58PrivateKey

```json theme={null}
{
  "pubKey": "<BASE58_ENCODED_PUBLIC_KEY>",
  "encoding": "base64PrivateKey",
  "secret": "asdf=="
}
```

## Transaction Deserialization

The [TransactionSkeleton](https://github.com/sava-software/sava/tree/main/sava-core/src/main/java/software/sava/core/tx/TransactionSkeleton.java)
interface provides a lightweight view over transaction data. Allowing for partial introspection or complete reconstruction of
a [Transaction](https://github.com/sava-software/sava/tree/main/sava-core/src/main/java/software/sava/core/tx/Transaction.java).

### Legacy

```java theme={null}
byte[] legacyTransactionData = ...;
var skeleton = TransactionSkeleton.deserializeSkeleton(legacyTransactionData);
AccountMeta[] accounts = skeleton.parseAccounts();
Instruction[] instructions = skeleton.parseLegacyInstructions();
Transaction transaction = skeleton.createTransaction()
```

### Versioned

```java theme={null}
byte[] v0TransactionData = ...;
var skeleton = TransactionSkeleton.deserializeSkeleton(v0TransactionData);
var instructionsWithoutTableAccounts = skeleton.parseInstructionsWithoutTableAccounts();

PublicKey[] tableAccounts =  skeleton.lookupTableAccounts();
// ... Fetch table accounts (See RPC) ...
AddressLookupTable lookupTable = ...;
AccountMeta[] accounts = skeleton.parseAccounts(lookupTable);
Instruction[] instructions = skeleton.parseInstructions(accounts);
Transaction transaction = skeleton.createTransaction(instructions, lookupTable);
```

## Creating Transactions

See the [program docs for typical transaction flows.](/libraries/programs#typical-transaction-flow)
