import requests
# ===== CONFIGURAÇÃO NECESSÁRIA =====
API_URL = "http://localhost:8000"
API_KEY = "pqc_sua_api_key_aqui" # API Key gerada no painel VexCrypt
SIG_KEY_ID = "key_xxxxxxxxxxxxxxxxxxxxxxxx" # ID da chave de assinatura (ML-DSA ou Falcon)
ALGORITHM = "ML-DSA-65" # Algoritmo: ML-DSA-44/65/87, Falcon-512/1024
# ===================================
headers = {
"X-API-Key": API_KEY,
"Content-Type": "application/json"
}
# ASSINAR DOCUMENTO
document = "Contrato de NDA — Empresa XYZ — 2026"
print("[LOG] ✍️ Assinando documento...")
sign_resp = requests.post(
f"{API_URL}/api/v1/external/sign",
headers=headers,
json={
"document_data": document,
"key_id": SIG_KEY_ID,
"algorithm": ALGORITHM
}
)
sign_data = sign_resp.json()
signature = sign_data["signature"]
public_key = sign_data["verification_data"]["public_key"]
print(f"[LOG] ✅ Documento assinado!")
print(f"[LOG] 🔑 Algoritmo: {sign_data['algorithm']}")
print(f"[LOG] 🆔 Operação: {sign_data['operation_id']}")
print(f"[LOG] 📝 Assinatura: {signature[:60]}...")
# VERIFICAR ASSINATURA
print("\n[LOG] 🔍 Verificando assinatura...")
verify_resp = requests.post(
f"{API_URL}/api/v1/external/verify",
headers=headers,
json={
"document_data": document,
"signature": signature,
"public_key": public_key,
"algorithm": ALGORITHM
}
)
verify_data = verify_resp.json()
print(f"[LOG] ✅ Verificação concluída!")
print(f"[LOG] 🛡️ Assinatura válida: {verify_data['valid']}")
print(f"[LOG] 🆔 Operação: {verify_data['operation_id']}")
import okhttp3.*;
import org.json.*;
import java.io.IOException;
public class VexCryptSignature {
// ===== CONFIGURAÇÃO NECESSÁRIA =====
private static final String API_URL = "http://localhost:8000";
private static final String API_KEY = "pqc_sua_api_key_aqui";
private static final String SIG_KEY_ID = "key_xxxxxxxxxxxxxxxxxxxxxxxx";
private static final String ALGORITHM = "ML-DSA-65";
// ===================================
private static final OkHttpClient client = new OkHttpClient();
private static final MediaType MEDIA_JSON = MediaType.get("application/json; charset=utf-8");
public static void main(String[] args) throws IOException {
String document = "Contrato de NDA — Empresa XYZ — 2026";
System.out.println("[LOG] ✍️ Assinando documento...");
// ASSINAR DOCUMENTO
JSONObject signPayload = new JSONObject()
.put("document_data", document)
.put("key_id", SIG_KEY_ID)
.put("algorithm", ALGORITHM);
Request signRequest = new Request.Builder()
.url(API_URL + "/api/v1/external/sign")
.addHeader("X-API-Key", API_KEY)
.post(RequestBody.create(signPayload.toString(), MEDIA_JSON))
.build();
Response signResponse = client.newCall(signRequest).execute();
JSONObject signData = new JSONObject(signResponse.body().string());
String signature = signData.getString("signature");
String publicKey = signData.getJSONObject("verification_data").getString("public_key");
String operationS = signData.getString("operation_id");
System.out.println("[LOG] ✅ Documento assinado!");
System.out.println("[LOG] 🔑 Algoritmo: " + signData.getString("algorithm"));
System.out.println("[LOG] 🆔 Operação: " + operationS);
System.out.println("[LOG] 📝 Assinatura: " + signature.substring(0, Math.min(60, signature.length())) + "...");
// VERIFICAR ASSINATURA
System.out.println("\n[LOG] 🔍 Verificando assinatura...");
JSONObject verifyPayload = new JSONObject()
.put("document_data", document)
.put("signature", signature)
.put("public_key", publicKey)
.put("algorithm", ALGORITHM);
Request verifyRequest = new Request.Builder()
.url(API_URL + "/api/v1/external/verify")
.addHeader("X-API-Key", API_KEY)
.post(RequestBody.create(verifyPayload.toString(), MEDIA_JSON))
.build();
Response verifyResponse = client.newCall(verifyRequest).execute();
JSONObject verifyData = new JSONObject(verifyResponse.body().string());
System.out.println("[LOG] ✅ Verificação concluída!");
System.out.println("[LOG] 🛡️ Assinatura válida: " + verifyData.getBoolean("valid"));
System.out.println("[LOG] 🆔 Operação: " + verifyData.getString("operation_id"));
}
}
// ===== CONFIGURAÇÃO NECESSÁRIA =====
const API_URL = 'http://localhost:8000';
const API_KEY = 'pqc_sua_api_key_aqui';
const SIG_KEY_ID = 'key_xxxxxxxxxxxxxxxxxxxxxxxx';
const ALGORITHM = 'ML-DSA-65';
// ===================================
const headers = {
'X-API-Key': API_KEY,
'Content-Type': 'application/json'
};
async function vexcryptSignature() {
try {
const document = 'Contrato de NDA — Empresa XYZ — 2026';
console.log('[LOG] ✍️ Assinando documento...');
// ASSINAR DOCUMENTO
const signResponse = await fetch(`${API_URL}/api/v1/external/sign`, {
method: 'POST',
headers,
body: JSON.stringify({
document_data: document,
key_id: SIG_KEY_ID,
algorithm: ALGORITHM
})
});
const signData = await signResponse.json();
const signature = signData.signature;
const publicKey = signData.verification_data.public_key;
console.log('[LOG] ✅ Documento assinado!');
console.log(`[LOG] 🔑 Algoritmo: ${signData.algorithm}`);
console.log(`[LOG] 🆔 Operação: ${signData.operation_id}`);
console.log(`[LOG] 📝 Assinatura: ${signature.substring(0, 60)}...`);
// VERIFICAR ASSINATURA
console.log('\n[LOG] 🔍 Verificando assinatura...');
const verifyResponse = await fetch(`${API_URL}/api/v1/external/verify`, {
method: 'POST',
headers,
body: JSON.stringify({
document_data: document,
signature,
public_key: publicKey,
algorithm: ALGORITHM
})
});
const verifyData = await verifyResponse.json();
console.log('[LOG] ✅ Verificação concluída!');
console.log(`[LOG] 🛡️ Assinatura válida: ${verifyData.valid}`);
console.log(`[LOG] 🆔 Operação: ${verifyData.operation_id}`);
} catch (error) {
console.error('[ERRO] ❌ Falha na operação:', error.message);
}
}
vexcryptSignature();
package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
)
// ===== CONFIGURAÇÃO NECESSÁRIA =====
const (
API_URL = "http://localhost:8000"
API_KEY = "pqc_sua_api_key_aqui"
SIG_KEY_ID = "key_xxxxxxxxxxxxxxxxxxxxxxxx"
ALGORITHM = "ML-DSA-65"
)
// ===================================
type SignRequest struct {
DocumentData string `json:"document_data"`
KeyID string `json:"key_id"`
Algorithm string `json:"algorithm"`
}
type VerificationData struct {
PublicKey string `json:"public_key"`
Algorithm string `json:"algorithm"`
}
type SignResponse struct {
Signature string `json:"signature"`
Algorithm string `json:"algorithm"`
KeyID string `json:"key_id"`
Timestamp string `json:"timestamp"`
OperationID interface{} `json:"operation_id"`
Message string `json:"message"`
VerificationData VerificationData `json:"verification_data"`
}
type VerifyRequest struct {
DocumentData string `json:"document_data"`
Signature string `json:"signature"`
PublicKey string `json:"public_key"`
Algorithm string `json:"algorithm"`
}
type VerifyResponse struct {
Valid bool `json:"valid"`
Algorithm string `json:"algorithm"`
Timestamp string `json:"timestamp"`
OperationID interface{} `json:"operation_id"`
Message string `json:"message"`
}
func post(url string, payload interface{}) []byte {
body, _ := json.Marshal(payload)
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(body))
req.Header.Set("X-API-Key", API_KEY)
req.Header.Set("Content-Type", "application/json")
resp, _ := (&http.Client{}).Do(req)
defer resp.Body.Close()
data, _ := io.ReadAll(resp.Body)
return data
}
func main() {
document := "Contrato de NDA — Empresa XYZ — 2026"
fmt.Println("[LOG] ✍️ Assinando documento...")
// ASSINAR DOCUMENTO
signBody := post(API_URL+"/api/v1/external/sign", SignRequest{
DocumentData: document,
KeyID: SIG_KEY_ID,
Algorithm: ALGORITHM,
})
var signData SignResponse
json.Unmarshal(signBody, &signData)
fmt.Println("[LOG] ✅ Documento assinado!")
fmt.Printf("[LOG] 🔑 Algoritmo: %s\n", signData.Algorithm)
fmt.Printf("[LOG] 🆔 Operação: %v\n", signData.OperationID)
fmt.Printf("[LOG] 📝 Assinatura: %.60s...\n", signData.Signature)
// VERIFICAR ASSINATURA
fmt.Println("\n[LOG] 🔍 Verificando assinatura...")
verifyBody := post(API_URL+"/api/v1/external/verify", VerifyRequest{
DocumentData: document,
Signature: signData.Signature,
PublicKey: signData.VerificationData.PublicKey,
Algorithm: ALGORITHM,
})
var verifyData VerifyResponse
json.Unmarshal(verifyBody, &verifyData)
fmt.Println("[LOG] ✅ Verificação concluída!")
fmt.Printf("[LOG] 🛡️ Assinatura válida: %v\n", verifyData.Valid)
fmt.Printf("[LOG] 🆔 Operação: %v\n", verifyData.OperationID)
}