Skip to content

flutter_sign_keypairDevice-bound ES256 signing, in hardware

A Flutter plugin that generates ECDSA P-256 keys inside AndroidKeyStore or the Apple Secure Enclave and signs there. The private key never enters Dart or app memory.

flutter_sign_keypair

At a glance ​

dart
import 'package:flutter_sign_keypair/flutter_sign_keypair.dart';

final signer = SignKeypair();

// Once, at enrolment: both keys, or neither.
final keys = await signer.generateDeviceKeys();
await registerDeviceWithBackend(
  ambient: keys.ambient.publicKey.toJson(), // {crv, kty, x, y}
  userPresent: keys.userPresent.publicKey.toJson(),
);

// On every authenticated request: the ambient key, which never prompts.
final jws = await signer.signCompactJws(payload: <String, dynamic>{
  'timestamp_ms': DateTime.now().millisecondsSinceEpoch,
  'method': 'POST',
  'path': '/v1/payments/transfer',
});

registerDeviceWithBackend stands for your own enrolment call. The plugin creates keys and signs with them; registering, checking and revoking keys is your backend's job.

Why it exists ​

A device-bound credential is only as strong as the place its private key lives. A pure-Dart signer has to load the raw private scalar into the Dart heap for every signature, where a debugger, a heap dump or a memory-disclosure bug can read it. This plugin moves both the key and the signing operation into the platform keystore, so there is nothing in the process to read: on Android the keystore hands back a key handle whose getEncoded() is null, and on both platforms the secure element computes the signature.

Where it runs ​

PlatformImplementationBacking it can report
AndroidAndroidKeyStore + java.security.SignaturestrongBox, tee, software
iOSSecurity framework, Secure Enclave when availablesecureEnclave, keychain
macOSThe same Swift source as iOSsecureEnclave, keychain
WebPure-Dart pointycastle fallbacksoftware
Windows / LinuxPure-Dart fallback; no native implementationsoftware

Only strongBox, secureEnclave and tee count as hardware-backed. See Platform notes & limitations for the details of each.

A fork, with credit

flutter_sign_keypair is a renamed fork of webank_secure_signer from ADORSYS-GIS/webank-mobile, released under the MIT License. See About for the details.

Released under the MIT License. A fork of webank_secure_signer.