diff --git a/.gitignore b/.gitignore
index 263a9d069a51fa757b20fafa0121d3a553213c4e..0e4fa11419e4dd70c931de6b150bfad4e750369c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -54,3 +54,5 @@ packages/dubp_rs/lib/ffi.dart
 
 # Rust things
 /target
+
+pubkeys.txt
diff --git a/lib/globals.dart b/lib/globals.dart
index b3a31701a89e8219c574b5c8462319f1a81e7127..a248f6cccf23343e58619e83f6c0b188a615b928 100644
--- a/lib/globals.dart
+++ b/lib/globals.dart
@@ -6,3 +6,4 @@ Directory walletsDirectory;
 String appVersion;
 SharedPreferences prefs;
 String endPointGVA;
+int ramSys;
diff --git a/lib/main.dart b/lib/main.dart
index 94db7af796bdeffc4d8832de9c5c4e4b60a1ecec..8f5312ddf50d6bc781cd7a9c27a108cf9e233630 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -1,6 +1,7 @@
 import 'package:dubp/dubp.dart';
 import 'package:gecko/globals.dart';
 import 'package:gecko/models/cesiumPlus.dart';
+import 'package:gecko/models/changePin.dart';
 import 'package:gecko/models/generateWallets.dart';
 import 'package:gecko/models/history.dart';
 import 'package:gecko/models/home.dart';
@@ -14,6 +15,7 @@ import 'package:provider/provider.dart';
 import 'package:sentry_flutter/sentry_flutter.dart';
 import 'package:flutter/foundation.dart';
 import 'package:shared_preferences/shared_preferences.dart';
+import "package:system_info/system_info.dart";
 
 final bool enableSentry = true;
 
@@ -28,6 +30,8 @@ Future<void> main() async {
   await _homeProvider.createDefaultAvatar();
   appVersion = await _homeProvider.getAppVersion();
   prefs = await SharedPreferences.getInstance();
+  ramSys = SysInfo.getTotalPhysicalMemory() ~/ 800000;
+  print("Votre appareil fait $ramSys de RAM.");
   final HiveStore _store =
       await HiveStore.open(path: '${appPath.path}/gqlCache');
 
@@ -91,6 +95,7 @@ class Gecko extends StatelessWidget {
           ChangeNotifierProvider(create: (_) => MyWalletsProvider()),
           ChangeNotifierProvider(create: (_) => GenerateWalletsProvider()),
           ChangeNotifierProvider(create: (_) => WalletOptionsProvider()),
+          ChangeNotifierProvider(create: (_) => ChangePinProvider()),
           ChangeNotifierProvider(create: (_) => CesiumPlusProvider())
         ],
         child: GraphQLProvider(
diff --git a/lib/models/changePin.dart b/lib/models/changePin.dart
new file mode 100644
index 0000000000000000000000000000000000000000..87bd694f0b36b618c54cedd86414cb425132195e
--- /dev/null
+++ b/lib/models/changePin.dart
@@ -0,0 +1,45 @@
+import 'dart:io';
+import 'package:dubp/dubp.dart';
+import 'package:flutter/foundation.dart';
+import 'package:flutter/material.dart';
+import 'dart:async';
+import 'package:gecko/globals.dart';
+
+class ChangePinProvider with ChangeNotifier {
+  bool ischangedPin = false;
+  TextEditingController newPin = new TextEditingController();
+
+  Future<NewWallet> get badWallet => null;
+
+  Future<NewWallet> changePin(_name, _oldPin) async {
+    try {
+      final _walletFile = Directory('${walletsDirectory.path}/$_name');
+      final _dewif =
+          File(_walletFile.path + '/wallet.dewif').readAsLinesSync()[0];
+
+      NewWallet newWalletFile = await DubpRust.changeDewifPin(
+        dewif: _dewif,
+        oldPin: _oldPin,
+      );
+
+      newPin.text = newWalletFile.pin;
+      ischangedPin = true;
+      notifyListeners();
+      return newWalletFile;
+    } catch (e) {
+      print('Impossible de changer le code PIN.');
+      return badWallet;
+    }
+  }
+
+  Future storeWallet(context, _name, _newWalletFile) async {
+    final Directory walletNameDirectory =
+        Directory('${walletsDirectory.path}/$_name');
+    final walletFile = File('${walletNameDirectory.path}/wallet.dewif');
+    print(_newWalletFile);
+
+    walletFile.writeAsString('${_newWalletFile.dewif}');
+    Navigator.pop(context);
+    return _name;
+  }
+}
diff --git a/lib/models/walletOptions.dart b/lib/models/walletOptions.dart
index eef7a765975b84b340faffb0a55344027cf9a1b2..cde9a4478cc0eb4b7d758912385a2a6b7732aeae 100644
--- a/lib/models/walletOptions.dart
+++ b/lib/models/walletOptions.dart
@@ -15,7 +15,7 @@ class WalletOptionsProvider with ChangeNotifier {
 
   Future<NewWallet> get badWallet => null;
 
-  Future _getPubkeyFromDewif(_dewif, _pin) async {
+  Future _getPubkeyFromDewif(_dewif, _pin, _pinLenght) async {
     String _pubkey;
     RegExp regExp = new RegExp(
       r'^[A-Z0-9]+$',
@@ -23,7 +23,7 @@ class WalletOptionsProvider with ChangeNotifier {
       multiLine: false,
     );
 
-    if (regExp.hasMatch(_pin) == true && _pin.length == 6) {
+    if (regExp.hasMatch(_pin) == true && _pin.length == _pinLenght) {
       print("Le format du code PIN est correct.");
     } else {
       print('Format de code PIN invalide');
@@ -50,14 +50,15 @@ class WalletOptionsProvider with ChangeNotifier {
     }
   }
 
-  Future readLocalWallet(String _name, String _pin) async {
+  Future readLocalWallet(String _name, String _pin, _pinLenght) async {
     isWalletUnlock = false;
     try {
       File _walletFile = File('${walletsDirectory.path}/$_name/wallet.dewif');
       String _localDewif = await _walletFile.readAsString();
       String _localPubkey;
 
-      if ((_localPubkey = await _getPubkeyFromDewif(_localDewif, _pin)) !=
+      if ((_localPubkey =
+              await _getPubkeyFromDewif(_localDewif, _pin, _pinLenght)) !=
           'false') {
         this.pubkey.text = _localPubkey;
         isWalletUnlock = true;
@@ -201,6 +202,7 @@ class WalletOptionsProvider with ChangeNotifier {
     final Directory walletNameDirectory =
         Directory('${walletsDirectory.path}/$_name');
     final walletFile = File('${walletNameDirectory.path}/wallet.dewif');
+    print(_newWalletFile);
 
     walletFile.writeAsString('${_newWalletFile.dewif}');
     Navigator.pop(context);
diff --git a/lib/screens/myWallets/changePin.dart b/lib/screens/myWallets/changePin.dart
index 77251aa2b274884158d4f51c4012aff23f1f088a..8141211a9028160dd841bc74a7beaed142595feb 100644
--- a/lib/screens/myWallets/changePin.dart
+++ b/lib/screens/myWallets/changePin.dart
@@ -1,7 +1,7 @@
 import 'package:flutter/foundation.dart';
 import 'package:flutter/material.dart';
 import 'package:dubp/dubp.dart';
-import 'package:gecko/models/walletOptions.dart';
+import 'package:gecko/models/changePin.dart';
 import 'dart:io';
 import 'package:provider/provider.dart';
 
@@ -17,68 +17,85 @@ class ChangePinScreen extends StatelessWidget with ChangeNotifier {
 
   @override
   Widget build(BuildContext context) {
-    WalletOptionsProvider _walletOptions =
-        Provider.of<WalletOptionsProvider>(context);
-    _walletOptions.changePin(walletName, oldPin);
-    return Scaffold(
-        resizeToAvoidBottomInset: false,
-        appBar: AppBar(
-            title: SizedBox(
-          height: 22,
-          child: Text(walletName),
-        )),
-        body: Center(
-            child: SafeArea(
-                child: Column(children: <Widget>[
-          SizedBox(height: 80),
-          Text(
-            'Choisissez un code secret autogénéré :',
-            textAlign: TextAlign.center,
-            style: TextStyle(
-                fontSize: 17.0,
-                color: Colors.grey[600],
-                fontWeight: FontWeight.w400),
-          ),
-          SizedBox(height: 30),
-          Container(
-            child: Stack(
-              alignment: Alignment.centerRight,
-              children: <Widget>[
-                TextField(
-                    enabled: true,
-                    controller: _walletOptions.newPin,
-                    maxLines: 1,
-                    textAlign: TextAlign.center,
-                    decoration: InputDecoration(),
-                    style: TextStyle(
-                        fontSize: 30.0,
-                        color: Colors.black,
-                        fontWeight: FontWeight.bold)),
-                IconButton(
-                  icon: Icon(Icons.replay),
-                  color: Color(0xffD28928),
-                  onPressed: () async {
-                    _newWalletFile =
-                        await _walletOptions.changePin(walletName, oldPin);
-                  },
+    ChangePinProvider _changePin = Provider.of<ChangePinProvider>(context);
+    // _walletOptions.changePin(walletName, oldPin);
+    // _walletOptions.newPin.text = _tmpPin;
+    return WillPopScope(
+        onWillPop: () {
+          _changePin.newPin.text = '';
+          return Future<bool>.value(true);
+        },
+        child: Scaffold(
+            resizeToAvoidBottomInset: false,
+            appBar: AppBar(
+                leading: IconButton(
+                    icon: Icon(Icons.arrow_back, color: Colors.black),
+                    onPressed: () {
+                      _changePin.newPin.text = '';
+                      Navigator.of(context).pop();
+                    }),
+                title: SizedBox(
+                  height: 22,
+                  child: Text(walletName),
+                )),
+            body: Center(
+                child: SafeArea(
+                    child: Column(children: <Widget>[
+              SizedBox(height: 80),
+              Text(
+                'Choisissez un code secret autogénéré :',
+                textAlign: TextAlign.center,
+                style: TextStyle(
+                    fontSize: 17.0,
+                    color: Colors.grey[600],
+                    fontWeight: FontWeight.w400),
+              ),
+              SizedBox(height: 30),
+              Container(
+                child: Stack(
+                  alignment: Alignment.centerRight,
+                  children: <Widget>[
+                    TextField(
+                        enabled: true,
+                        controller: _changePin.newPin,
+                        maxLines: 1,
+                        textAlign: TextAlign.center,
+                        decoration: InputDecoration(),
+                        style: TextStyle(
+                            fontSize: 30.0,
+                            color: Colors.black,
+                            fontWeight: FontWeight.bold)),
+                    IconButton(
+                      icon: Icon(Icons.replay),
+                      color: Color(0xffD28928),
+                      onPressed: () async {
+                        _newWalletFile =
+                            await _changePin.changePin(walletName, oldPin);
+                      },
+                    ),
+                  ],
                 ),
-              ],
-            ),
-          ),
-          SizedBox(height: 30),
-          SizedBox(
-            width: 200,
-            height: 50,
-            child: ElevatedButton(
-                style: ElevatedButton.styleFrom(
-                  elevation: 12,
-                  primary: Colors.green[400], //Color(0xffFFD68E), // background
-                  onPrimary: Colors.black, // foreground
-                ),
-                onPressed: () => _walletOptions.storeWallet(
-                    context, walletName, _newWalletFile),
-                child: Text('Confirmer', style: TextStyle(fontSize: 28))),
-          )
-        ]))));
+              ),
+              SizedBox(height: 30),
+              SizedBox(
+                width: 200,
+                height: 50,
+                child: ElevatedButton(
+                    style: ElevatedButton.styleFrom(
+                      elevation: 12,
+                      primary:
+                          Colors.green[400], //Color(0xffFFD68E), // background
+                      onPrimary: Colors.black, // foreground
+                    ),
+                    onPressed: _changePin.newPin.text != ''
+                        ? () {
+                            _changePin.newPin.text = '';
+                            _changePin.storeWallet(
+                                context, walletName, _newWalletFile);
+                          }
+                        : null,
+                    child: Text('Confirmer', style: TextStyle(fontSize: 28))),
+              )
+            ])))));
   }
 }
diff --git a/lib/screens/myWallets/walletOptions.dart b/lib/screens/myWallets/walletOptions.dart
index 581674463b67f73182c34243e035e43942aadd43..caa9478da62894b0d34c19d3b6fd7e29d3b845d7 100644
--- a/lib/screens/myWallets/walletOptions.dart
+++ b/lib/screens/myWallets/walletOptions.dart
@@ -1,6 +1,7 @@
 import 'package:flutter/foundation.dart';
 import 'package:flutter/material.dart';
 import 'package:dubp/dubp.dart';
+import 'package:gecko/globals.dart';
 import 'package:gecko/models/myWallets.dart';
 import 'package:gecko/models/walletOptions.dart';
 import 'package:gecko/screens/myWallets/changePin.dart';
@@ -21,6 +22,7 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
   bool hasError = false;
   var pinColor = Color(0xffF9F9F1);
   var walletPin = '';
+  int _pinLenght;
 
   Future<NewWallet> get badWallet => null;
 
@@ -33,6 +35,11 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
         Provider.of<MyWalletsProvider>(context);
     errorController = StreamController<ErrorAnimationType>();
     // _walletOptions.isWalletUnlock = false;
+    if (ramSys <= 3000) {
+      _pinLenght = 6;
+    } else {
+      _pinLenght = 5;
+    }
 
     return WillPopScope(
         onWillPop: () {
@@ -45,8 +52,8 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
                 leading: IconButton(
                     icon: Icon(Icons.arrow_back, color: Colors.black),
                     onPressed: () {
-                      Navigator.of(context).pop();
                       _walletOptions.isWalletUnlock = false;
+                      Navigator.of(context).pop();
                     }),
                 title: SizedBox(
                   height: 22,
@@ -201,13 +208,13 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
                                       color: Colors.green.shade600,
                                       fontWeight: FontWeight.bold,
                                     ),
-                                    length: 6,
+                                    length: _pinLenght,
                                     obscureText: false,
                                     obscuringCharacter: '*',
                                     animationType: AnimationType.fade,
                                     validator: (v) {
-                                      if (v.length < 6) {
-                                        return "Votre code PIN fait 6 caractères";
+                                      if (v.length < _pinLenght) {
+                                        return "Votre code PIN fait $_pinLenght caractères";
                                       } else {
                                         return null;
                                       }
@@ -243,7 +250,8 @@ class WalletOptions extends StatelessWidget with ChangeNotifier {
                                       final resultWallet =
                                           await _walletOptions.readLocalWallet(
                                               this.walletName,
-                                              _pin.toUpperCase());
+                                              _pin.toUpperCase(),
+                                              _pinLenght);
                                       if (resultWallet == 'bad') {
                                         errorController.add(ErrorAnimationType
                                             .shake); // Triggering error shake animation