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

# Verify Signatures

> Galadriel Verified Inference API provides LLM inferences results that are signed by the TEE private key. This page goes over the details on how to validate if the signatures are correct.

<Info>
  Please see the [quickstart](quickstart) to get an LLM inference response
</Info>

<Steps>
  <Step title="Install Sentience SDK">
    ```
    pip install sentience
    ```
  </Step>

  <Step title="Call the verification code">
    Run the following code

    <CodeGroup>
      ```python PythonSDK theme={null}
      import sentience
      from openai import OpenAI

      client = OpenAI(
          base_url="https://api.galadriel.com/v1/verified",
          api_key="Bearer GALADRIEL_API_KEY",
      )

      completion = client.chat.completions.create(
          model="gpt-4o",
          messages=[
              {"role": "system", "content": "You are a helpful assistant."},
              {"role": "user", "content": "Hello!"},
          ],
      )

      # Verifying proof is just oneliner after making the request:
      is_valid = sentience.verify_signature(completion)
      print("is_valid:", is_valid)
      ```

      ```python Python theme={null}
      # See quick start on how to get the `hash`, `signature` and
      # `public_key` fields from LLM inference

      # pip install pynacl
      # python verify.py
      import binascii
      import nacl.signing
      import nacl.exceptions

      # Given values
      # TODO: change to your values
      hash = "c847e98b1abf528f988c0253840616405a014ef2494e7a1b6c8d35e90413dd0a"
      signature = "68603b802f1e293dbf21bb1004bd08bca272fc70b6d00556f2a06b35949319533ad527c614c063836601aa00c8ca960dc600cad990df1ff8ff18079a09561d07"
      public_key = "835cc0e84c2a5190561d7c2eaf10eb2597cbe7a71541084c5edea32b60bc5e68"

      # Decode the public key from base58 into raw bytes
      public_key_bytes = binascii.unhexlify(public_key)

      # Decode the hash (message) and signature from hex
      message_bytes = binascii.unhexlify(hash)
      signature_bytes = binascii.unhexlify(signature)

      # Create a VerifyKey object from the public key bytes
      verify_key = nacl.signing.VerifyKey(public_key_bytes)

      try:
          # If verify() does not raise an exception, the signature is valid.
          verify_key.verify(message_bytes, signature_bytes)
          print("Signature is valid!")
      except nacl.exceptions.BadSignatureError:
          print("Signature is invalid!")
      ```

      ```javascript Javascript theme={null}
      // See quick start on how to get the `hash`, `signature` and
      // `public_key` fields from LLM inference

      import nacl from 'tweetnacl';

      // Given values
      // TODO: change to your values
      const hash = "c847e98b1abf528f988c0253840616405a014ef2494e7a1b6c8d35e90413dd0a";
      const signature = "68603b802f1e293dbf21bb1004bd08bca272fc70b6d00556f2a06b35949319533ad527c614c063836601aa00c8ca960dc600cad990df1ff8ff18079a09561d07";
      const publicKey = "835cc0e84c2a5190561d7c2eaf10eb2597cbe7a71541084c5edea32b60bc5e68";

      // Decode the public key from hex
      const publicKeyBytes = Buffer.from(publicKey, 'hex');

      // Decode the message (hash) and signature from hex
      const messageBytes = Buffer.from(hash, 'hex');
      const signatureBytes = Buffer.from(signature, 'hex');

      // Verify the signature
      const isValid = nacl.sign.detached.verify(messageBytes, signatureBytes, publicKeyBytes);

      if (isValid) {
        console.log("Signature is valid!");
      } else {
        console.log("Signature is invalid!");
      }
      ```
    </CodeGroup>
  </Step>
</Steps>

### What's next?

* To see more details about the API check out the full [API docs](/api-reference/proof-of-sentience-API)
* To see how to verify the attestation [Verify Attestation](/for-agents-developers/verify-attestation)
